Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-astreamer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-apps-astreamer
Commits
594cf1ed
Commit
594cf1ed
authored
Feb 18, 2017
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: spawn several streamers from main
parent
6e2f0b2d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
13 deletions
+43
-13
Makefile
src/Makefile
+1
-1
main.cpp
src/main.cpp
+42
-12
No files found.
src/Makefile
View file @
594cf1ed
PROG
=
str
CXXFLAGS
+=
-Wall
-O2
-I
$(STAGING_DIR_HOST)
/usr/include-uapi
CXXFLAGS
+=
-Wall
-O2
-
std
=
c++11
-
I
$(STAGING_DIR_HOST)
/usr/include-uapi
LDFLAGS
+=
-s
-lpthread
-lasound
SRCS
=
main.cpp streamer.cpp audio.cpp video.cpp socket.cpp rtsp.cpp rtp_stream.cpp helpers.cpp parameters.cpp
...
...
src/main.cpp
View file @
594cf1ed
/**
* @file
FILENAME
* @brief
BRIEF DESCRIPTION
* @copyright Copyright (C)
YEAR
Elphel Inc.
* @file
main.cpp
* @brief
Spawn single instance of streamer for each sensor port.
* @copyright Copyright (C)
2017
Elphel Inc.
* @author AUTHOR <EMAIL>
*
* @par License:
...
...
@@ -17,11 +17,12 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include <iostream>
#include <string>
#include <map>
#include <array>
#include "streamer.h"
...
...
@@ -29,30 +30,59 @@ using namespace std;
#include <unistd.h>
#include <linux/sysctl.h>
#include <elphel/c313a.h>
#include <pthread.h>
/**
* Unconditionally cancel all threads.
* @param threads an array of thread pointers
* @return None
*/
void
clean_up
(
array
<
pthread_t
,
SENSOR_PORTS
>
&
threads
)
{
for
(
array
<
pthread_t
,
SENSOR_PORTS
>::
iterator
it
=
threads
.
begin
();
it
!=
threads
.
end
();
it
++
)
pthread_cancel
(
*
it
);
}
int
main
(
int
argc
,
char
*
argv
[])
{
string
opt
;
map
<
string
,
string
>
args
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
argv
[
i
][
0
]
==
'-'
&&
argv
[
i
][
1
]
!=
'\0'
)
{
if
(
opt
!=
""
)
array
<
pthread_t
,
SENSOR_PORTS
>
threads
;
array
<
Streamer
*
,
SENSOR_PORTS
>
streamers
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
argv
[
i
][
0
]
==
'-'
&&
argv
[
i
][
1
]
!=
'\0'
)
{
if
(
opt
!=
""
)
args
[
opt
]
=
""
;
opt
=
&
argv
[
i
][
1
];
continue
;
}
else
{
if
(
opt
!=
""
)
{
if
(
opt
!=
""
)
{
args
[
opt
]
=
argv
[
i
];
opt
=
""
;
}
}
}
if
(
opt
!=
""
)
if
(
opt
!=
""
)
args
[
opt
]
=
""
;
for
(
map
<
string
,
string
>::
iterator
it
=
args
.
begin
();
it
!=
args
.
end
();
it
++
)
{
for
(
map
<
string
,
string
>::
iterator
it
=
args
.
begin
();
it
!=
args
.
end
();
it
++
)
{
cerr
<<
"|"
<<
(
*
it
).
first
<<
"| == |"
<<
(
*
it
).
second
<<
"|"
<<
endl
;
}
Streamer
*
streamer
=
new
Streamer
(
args
);
streamer
->
Main
();
for
(
int
i
=
0
;
i
<
SENSOR_PORTS
;
i
++
)
{
pthread_attr_t
attr
;
streamers
[
i
]
=
new
Streamer
(
args
);
pthread_attr_init
(
&
attr
);
pthread_attr_setdetachstate
(
&
attr
,
PTHREAD_CREATE_DETACHED
);
if
(
!
pthread_create
(
&
threads
[
i
],
&
attr
,
Streamer
::
pthread_f
,
(
void
*
)
streamers
[
i
]))
{
cerr
<<
"Can not spawn streamer thread for port "
<<
to_string
(
i
)
<<
endl
;
clean_up
(
threads
);
exit
(
EXIT_FAILURE
);
}
pthread_attr_destroy
(
&
attr
);
}
for
(
array
<
pthread_t
,
SENSOR_PORTS
>::
iterator
it
=
threads
.
begin
();
it
!=
threads
.
end
();
it
++
)
pthread_join
(
*
it
,
NULL
);
return
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment