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

@ -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