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
a788783f
Commit
a788783f
authored
Feb 21, 2017
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: compile RTSP server class without errors
parent
6f34e998
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
59 deletions
+63
-59
rtsp.cpp
src/rtsp.cpp
+55
-55
rtsp.h
src/rtsp.h
+8
-4
No files found.
src/rtsp.cpp
View file @
a788783f
/**
/**
* @file
FILENAME
* @file
rtsp.cpp
* @brief
BRIEF DESCRIPTION
* @brief
RTSP server implementation
* @copyright Copyright (C)
YEAR
Elphel Inc.
* @copyright Copyright (C)
2017
Elphel Inc.
* @author AUTHOR <EMAIL>
* @author AUTHOR <EMAIL>
*
*
* @par License:
* @par License:
...
@@ -21,17 +21,16 @@
...
@@ -21,17 +21,16 @@
#include "rtsp.h"
#include "rtsp.h"
#include "helpers.h"
#include "helpers.h"
#include "parameters.h"
#include <string.h>
#include <string.h>
#include <vector>
#include <vector>
using
namespace
std
;
using
namespace
std
;
#undef RTSP_DEBUG
//
#undef RTSP_DEBUG
#undef RTSP_DEBUG_2
//
#undef RTSP_DEBUG_2
//
#define RTSP_DEBUG
#define RTSP_DEBUG
//
#define RTSP_DEBUG_2
#define RTSP_DEBUG_2
#ifdef RTSP_DEBUG
#ifdef RTSP_DEBUG
#define D(a) a
#define D(a) a
...
@@ -126,13 +125,14 @@ string _Responce::serialize() {
...
@@ -126,13 +125,14 @@ string _Responce::serialize() {
return
rez
;
return
rez
;
}
}
RTSP_Server
::
RTSP_Server
(
int
(
*
h
)(
void
*
,
RTSP_Server
*
,
RTSP_Server
::
event
),
void
*
handler_data
,
Session
*
_session
)
{
RTSP_Server
::
RTSP_Server
(
int
(
*
h
)(
void
*
,
RTSP_Server
*
,
RTSP_Server
::
event
),
void
*
handler_data
,
Parameters
*
pars
,
Session
*
_session
)
{
socket_main_1
=
NULL
;
socket_main_1
=
NULL
;
socket_main_2
=
NULL
;
socket_main_2
=
NULL
;
// socket_main_3 = NULL;
// socket_main_3 = NULL;
handler_f
=
h
;
handler_f
=
h
;
this
->
handler_data
=
handler_data
;
this
->
handler_data
=
handler_data
;
session
=
_session
;
session
=
_session
;
params
=
pars
;
// _busy = NULL;
// _busy = NULL;
}
}
...
@@ -143,82 +143,82 @@ void RTSP_Server::main(void) {
...
@@ -143,82 +143,82 @@ void RTSP_Server::main(void) {
// once opened socket to listen can be closed and reopen again by Socket's implementation:
// once opened socket to listen can be closed and reopen again by Socket's implementation:
// opened port assigned to process id and is keeped all time while process is alive
// opened port assigned to process id and is keeped all time while process is alive
// so, keep this socket
// so, keep this socket
if
(
socket_main_1
==
NULL
)
{
if
(
socket_main_1
==
NULL
)
{
socket_main_1
=
new
Socket
(
""
,
RTSP_PORT_1
);
socket_main_1
=
new
Socket
(
""
,
RTSP_PORT_1
);
socket_main_1
->
listen
(
2
);
socket_main_1
->
listen
(
2
);
}
}
if
(
socket_main_2
==
NULL
)
{
if
(
socket_main_2
==
NULL
)
{
socket_main_2
=
new
Socket
(
""
,
RTSP_PORT_2
);
socket_main_2
=
new
Socket
(
""
,
RTSP_PORT_2
);
socket_main_2
->
listen
(
2
);
socket_main_2
->
listen
(
2
);
}
}
/*
/*
if(socket_main_3 == NULL) {
if(socket_main_3 == NULL) {
socket_main_3 = new Socket("", RTSP_PORT_3);
socket_main_3 = new Socket("", RTSP_PORT_3);
socket_main_3->listen(2);
socket_main_3->listen(2);
}
}
*/
*/
/*
/*
if(socket_main == NULL) {
if(socket_main == NULL) {
// socket_main = new Socket("", 554);
// socket_main = new Socket("", 554);
//cerr << "create socket to listen port" << endl;
//cerr << "create socket to listen port" << endl;
socket_main = new Socket("", RTSP_PORT);
socket_main = new Socket("", RTSP_PORT);
// Socket *socket_1 = new Socket("", 554);
// Socket *socket_1 = new Socket("", 554);
// Socket *socket_2 = new Socket("", 8554);
// Socket *socket_2 = new Socket("", 8554);
// Socket *socket_3 = new Socket("", 7070);
// Socket *socket_3 = new Socket("", 7070);
socket_main->listen(2);
socket_main->listen(2);
} else {
} else {
//cerr << "main socket already exist" << endl;
//cerr << "main socket already exist" << endl;
}
}
*/
*/
s
.
push_back
(
socket_main_1
);
s
.
push_back
(
socket_main_1
);
s
.
push_back
(
socket_main_2
);
s
.
push_back
(
socket_main_2
);
// s.push_back(socket_main_3);
// s.push_back(socket_main_3);
D
(
static
int
count
=
0
;)
D
(
static
int
count
=
0
;)
bool
to_poll
=
true
;
bool
to_poll
=
true
;
// Parameters *params = Parameters::instance();
// Parameters *params = Parameters::instance();
while
(
true
)
{
while
(
true
)
{
if
(
to_poll
)
{
if
(
to_poll
)
{
int
poll_rez
=
Socket
::
poll
(
s
,
500
);
int
poll_rez
=
Socket
::
poll
(
s
,
500
);
D
(
{
if
(
count
<
5
)
{
D
(
{
if
(
count
<
5
)
{
cerr
<<
"poll..."
<<
endl
;
cerr
<<
"poll..."
<<
endl
;
count
++
;
count
++
;
}
}
});
});
// TODO here:
// TODO here:
// if client connected - check for changes of all possible parameters
// if client connected - check for changes of all possible parameters
// if client not connected - check only about enable/disable bit to prevent overhead
// if client not connected - check only about enable/disable bit to prevent overhead
if
(
handler
(
PARAMS_WAS_CHANGED
))
{
if
(
handler
(
PARAMS_WAS_CHANGED
))
{
// stop all sessions, and restart streamer
// stop all sessions, and restart streamer
handler
(
RESET
);
handler
(
RESET
);
break
;
break
;
}
}
if
(
poll_rez
==
0
)
{
if
(
poll_rez
==
0
)
{
/// poll was finished with timeout, not socket event
/// poll was finished with timeout, not socket event
to_poll
=
true
;
to_poll
=
true
;
continue
;
continue
;
}
}
}
}
to_poll
=
true
;
to_poll
=
true
;
for
(
list
<
Socket
*>::
iterator
it
=
s
.
begin
();
it
!=
s
.
end
();
it
++
)
{
for
(
list
<
Socket
*>::
iterator
it
=
s
.
begin
();
it
!=
s
.
end
();
it
++
)
{
Socket
::
state
state
=
(
*
it
)
->
state_refresh
();
Socket
::
state
state
=
(
*
it
)
->
state_refresh
();
if
(
state
==
Socket
::
STATE_IN
||
state
==
Socket
::
STATE_DISCONNECT
)
{
if
(
state
==
Socket
::
STATE_IN
||
state
==
Socket
::
STATE_DISCONNECT
)
{
D2
(
cerr
<<
endl
<<
"something happen on the socket!"
<<
endl
;)
D2
(
cerr
<<
endl
<<
"something happen on the socket!"
<<
endl
;)
if
(
*
it
==
socket_main_1
||
*
it
==
socket_main_2
)
{
// || *it == socket_main_3) {
if
(
*
it
==
socket_main_1
||
*
it
==
socket_main_2
)
{
// || *it == socket_main_3) {
// Socket *in = socket_main->accept();
// Socket *in = socket_main->accept();
Socket
*
in
=
(
*
it
)
->
accept
();
Socket
*
in
=
(
*
it
)
->
accept
();
if
(
in
)
{
if
(
in
)
{
in
->
set_so_keepalive
(
1
);
in
->
set_so_keepalive
(
1
);
D2
(
cerr
<<
"processed - s.push_back(in)"
<<
endl
;)
D2
(
cerr
<<
"processed - s.push_back(in)"
<<
endl
;)
D2
(
fprintf
(
stderr
,
"added : 0x%08X
\n
"
,
in
);)
D2
(
fprintf
(
stderr
,
"added : 0x%p
\n
"
,
in
);)
s
.
push_back
(
in
);
s
.
push_back
(
in
);
}
}
}
else
{
}
else
{
// check for remove closed socket !
// check for remove closed socket !
D2
(
cerr
<<
"was with non-main socket"
<<
endl
;)
D2
(
cerr
<<
"was with non-main socket"
<<
endl
;)
if
(
!
process
(
*
it
))
{
if
(
!
process
(
*
it
))
{
D2
(
cerr
<<
"process failed - remove it!"
<<
endl
;)
D2
(
cerr
<<
"process failed - remove it!"
<<
endl
;)
D2
(
fprintf
(
stderr
,
"delete: 0x%08X
\n
"
,
*
it
);)
D2
(
fprintf
(
stderr
,
"delete: 0x%p
\n
"
,
*
it
);)
delete
*
it
;
delete
*
it
;
s
.
remove
(
*
it
);
s
.
remove
(
*
it
);
// check about counters etc...
// check about counters etc...
...
@@ -230,10 +230,10 @@ D2(fprintf(stderr, "delete: 0x%08X\n", *it);)
...
@@ -230,10 +230,10 @@ D2(fprintf(stderr, "delete: 0x%08X\n", *it);)
}
}
}
}
// stop all - by TEARDOWN command
// stop all - by TEARDOWN command
for
(
list
<
Socket
*>::
iterator
it
=
s
.
begin
();
it
!=
s
.
end
();
it
++
)
{
for
(
list
<
Socket
*>::
iterator
it
=
s
.
begin
();
it
!=
s
.
end
();
it
++
)
{
// keep the 'main' i.e. server socket
// keep the 'main' i.e. server socket
if
(
*
it
!=
socket_main_1
&&
*
it
!=
socket_main_2
)
{
// && *it != socket_main_3) {
if
(
*
it
!=
socket_main_1
&&
*
it
!=
socket_main_2
)
{
// && *it != socket_main_3) {
D2
(
fprintf
(
stderr
,
"delete: 0x%08X
\n
"
,
*
it
);)
D2
(
fprintf
(
stderr
,
"delete: 0x%p
\n
"
,
*
it
);)
delete
*
it
;
delete
*
it
;
}
}
}
}
...
@@ -307,7 +307,7 @@ D(cerr << __FILE__<< ":"<< __FUNCTION__ << ":" <<__LINE__ << " part_REQUEST: " <
...
@@ -307,7 +307,7 @@ D(cerr << __FILE__<< ":"<< __FUNCTION__ << ":" <<__LINE__ << " part_REQUEST: " <
// process...
// process...
request
=
new
_Request
(
req
);
request
=
new
_Request
(
req
);
Parameters
*
params
=
Parameters
::
instance
();
//
Parameters *params = Parameters::instance();
responce
=
new
_Responce
();
responce
=
new
_Responce
();
// responce->add_field("CSeq", (*request->get_fields().find("CSeq")).second);
// responce->add_field("CSeq", (*request->get_fields().find("CSeq")).second);
responce
->
add_field
(
"CSeq"
,
(
request
->
get_fields
())[
"CSeq"
]);
responce
->
add_field
(
"CSeq"
,
(
request
->
get_fields
())[
"CSeq"
]);
...
...
src/rtsp.h
View file @
a788783f
/**
/**
* @file
FILENAME
* @file
rtsp.h
* @brief
BRIEF DESCRIPTION
* @brief
RTSP server implementation
* @copyright Copyright (C)
YEAR
Elphel Inc.
* @copyright Copyright (C)
2017
Elphel Inc.
* @author AUTHOR <EMAIL>
* @author AUTHOR <EMAIL>
*
*
* @par License:
* @par License:
...
@@ -25,11 +25,14 @@
...
@@ -25,11 +25,14 @@
//#include "types.h"
//#include "types.h"
#include "session.h"
#include "session.h"
#include "socket.h"
#include "socket.h"
#include "parameters.h"
#include <map>
#include <map>
#include <list>
#include <list>
#include <string>
#include <string>
#include <iostream>
#include <iostream>
#include <cstdio>
#include <cstdlib>
using
namespace
std
;
using
namespace
std
;
...
@@ -81,7 +84,7 @@ public:
...
@@ -81,7 +84,7 @@ public:
};
};
// if transport == NULL - wait for set_transport(), when client connected and ask DESCRIBE
// if transport == NULL - wait for set_transport(), when client connected and ask DESCRIBE
RTSP_Server
(
int
(
*
h
)(
void
*
,
RTSP_Server
*
,
RTSP_Server
::
event
),
void
*
handler_data
,
Session
*
_session
=
NULL
);
RTSP_Server
(
int
(
*
h
)(
void
*
,
RTSP_Server
*
,
RTSP_Server
::
event
),
void
*
handler_data
,
Parameters
*
pars
,
Session
*
_session
=
NULL
);
~
RTSP_Server
();
~
RTSP_Server
();
// deprecated
// deprecated
...
@@ -111,6 +114,7 @@ protected:
...
@@ -111,6 +114,7 @@ protected:
Socket
*
socket_main_1
;
Socket
*
socket_main_1
;
Socket
*
socket_main_2
;
Socket
*
socket_main_2
;
// Socket *socket_main_3;
// Socket *socket_main_3;
Parameters
*
params
;
};
};
#endif // _RTSP_H_
#endif // _RTSP_H_
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