1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

add librtmp demo srs_publish

This commit is contained in:
winlin 2014-03-01 23:24:53 +08:00
parent aa5d28ed85
commit 713b05541b
12 changed files with 172 additions and 34 deletions

View file

@ -77,8 +77,8 @@ int SrsForwarder::on_publish(SrsRequest* req, std::string forward_server)
stream_name = req->stream;
server = forward_server;
std::string s_port = RTMP_DEFAULT_PORTS;
port = RTMP_DEFAULT_PORT;
std::string s_port = RTMP_DEFAULT_PORT;
port = ::atoi(RTMP_DEFAULT_PORT);
size_t pos = forward_server.find(":");
if (pos != std::string::npos) {

View file

@ -29,7 +29,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// current release version
#define RTMP_SIG_SRS_VERSION "0.9.8"
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "8"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "srs"
#define RTMP_SIG_SRS_ROLE "origin server"

View file

@ -22,3 +22,78 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_librtmp.hpp>
#include <stdlib.h>
#include <srs_protocol_rtmp.hpp>
/**
* the stream over epoll: never wait for data coming, that is async mode.
*/
class SimpleSocketStream
{
private:
int sock;
public:
SimpleSocketStream(int fd){
sock = fd;
}
virtual ~SimpleSocketStream() {
::close(sock);
}
public:
};
/**
* export runtime context.
*/
struct Context
{
SrsRtmpClient* rtmp;
SimpleSocketStream* stream;
int stream_id;
Context() {
rtmp = NULL;
stream = NULL;
stream_id = 0;
}
virtual ~Context() {
srs_freep(rtmp);
srs_freep(stream);
}
};
#ifdef __cplusplus
extern "C"{
#endif
srs_rtmp_t srs_rtmp_create(){
Context* context = new Context();
return context;
}
void srs_rtmp_destroy(srs_rtmp_t rtmp){
srs_assert(rtmp != NULL);
Context* context = (Context*)rtmp;
srs_freep(context);
}
int srs_version_major()
{
return ::atoi(VERSION_MAJOR);
}
int srs_version_minor()
{
return ::atoi(VERSION_MINOR);
}
int srs_version_revision()
{
return ::atoi(VERSION_REVISION);
}
#ifdef __cplusplus
}
#endif

View file

@ -25,7 +25,36 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_LIB_RTMP_HPP
/*
#include <srs_librtmp.hpp>
#include <srs_librtmp.h>
*/
#ifdef __cplusplus
extern "C"{
#endif
// the output handler.
typedef void* srs_rtmp_t;
/**
* create a rtmp protocol stack.
* @return a rtmp handler, or NULL if error occured.
*/
srs_rtmp_t srs_rtmp_create();
/**
* close a rtmp protocl stack.
*/
void srs_rtmp_destroy(srs_rtmp_t rtmp);
/**
* get protocol stack version
*/
int srs_version_major();
int srs_version_minor();
int srs_version_revision();
#ifdef __cplusplus
}
#endif
#endif

View file

@ -116,7 +116,7 @@ int SrsRequest::discovery_app()
srs_verbose("discovery vhost=%s", vhost.c_str());
}
port = RTMP_DEFAULT_PORTS;
port = RTMP_DEFAULT_PORT;
if ((pos = vhost.find(":")) != std::string::npos) {
port = vhost.substr(pos + 1);
vhost = vhost.substr(0, pos);

View file

@ -29,8 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core.hpp>
#define RTMP_DEFAULT_PORT 1935
#define RTMP_DEFAULT_PORTS "1935"
#define RTMP_DEFAULT_PORT "1935"
// the default chunk size for system.
#define SRS_CONF_DEFAULT_CHUNK_SIZE 60000

View file

@ -72,6 +72,7 @@ file
..\app\srs_core_source.hpp,
..\app\srs_core_source.cpp,
research readonly separator,
..\..\research\librtmp\srs_publish.c,
..\..\research\hls\ts_info.cc;
mainconfig