本文整理汇总了C++中RTMP_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ RTMP_Init函数的具体用法?C++ RTMP_Init怎么用?C++ RTMP_Init使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTMP_Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtmp_probe
static int
rtmp_probe(const char *url0, char *errbuf, size_t errlen, int timeout_ms)
{
RTMP *r;
char *url = mystrdupa(url0);
r = RTMP_Alloc();
RTMP_Init(r, NULL);
if(!RTMP_SetupURL(r, url)) {
snprintf(errbuf, errlen, "Unable to setup RTMP-session");
RTMP_Free(r);
return BACKEND_PROBE_FAIL;
}
if(!RTMP_Connect(r, NULL, errbuf, errlen, timeout_ms)) {
RTMP_Close(r);
RTMP_Free(r);
return BACKEND_PROBE_FAIL;
}
RTMP_SetReadTimeout(r, timeout_ms);
if(!RTMP_ConnectStream(r, 0)) {
snprintf(errbuf, errlen, "Unable to connect RTMP-stream");
RTMP_Close(r);
RTMP_Free(r);
return BACKEND_PROBE_FAIL;
}
RTMP_Close(r);
RTMP_Free(r);
return BACKEND_PROBE_OK;
}
示例2: m_rtmp
QRtmp::QRtmp() :
m_rtmp(new RTMP_private),
m_swfSize(0),
m_nSkipKeyFrames(0),
m_bufferTime(10 * 60 * 60 * 1000), /* 10 hours default */
m_bOverrideBufferTime(false),
m_bLiveStream(true),
m_port(-1),
m_proto(Undefined),
m_timeout(30),
dStartOffset(0), dStopOffset(0), dSeek(0),
m_bResume(false),
m_stop(false),
m_percent(0),
m_duration(0),
m_streamIsRunning(false)
{
if(!m_socketsInitialized)
{
#ifdef WIN32
WORD version;
WSADATA wsaData;
version = MAKEWORD(1, 1);
m_socketsInitialized = (WSAStartup(version, &wsaData) == 0);
#else
m_socketsInitialized = true;
#endif
}
RTMP_Init(m_rtmp);
}
示例3: gst_rtmp_sink_start
static gboolean
gst_rtmp_sink_start (GstBaseSink * basesink)
{
GstRTMPSink *sink = GST_RTMP_SINK (basesink);
if (!sink->uri) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
("Please set URI for RTMP output"), ("No URI set before starting"));
return FALSE;
}
sink->rtmp_uri = g_strdup (sink->uri);
sink->rtmp = RTMP_Alloc ();
RTMP_Init (sink->rtmp);
if (!RTMP_SetupURL (sink->rtmp, sink->rtmp_uri)) {
GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
("Failed to setup URL '%s'", sink->uri));
RTMP_Free (sink->rtmp);
sink->rtmp = NULL;
g_free (sink->rtmp_uri);
sink->rtmp_uri = NULL;
return FALSE;
}
GST_DEBUG_OBJECT (sink, "Created RTMP object");
/* Mark this as an output connection */
RTMP_EnableWrite (sink->rtmp);
sink->first = TRUE;
return TRUE;
}
示例4: RTMP_Alloc
/*
* Class: net_butterflytv_rtmp_client_RtmpClient
* Method: open
* Signature: (Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_net_ossrs_sea_RtmpClient_open
(JNIEnv * env, jobject thiz, jstring url_, jboolean isPublishMode) {
const char *url = (*env)->GetStringUTFChars(env, url_, 0);
rtmp = RTMP_Alloc();
if (rtmp == NULL) {
return -1;
}
RTMP_Init(rtmp);
int ret = RTMP_SetupURL(rtmp, url);
if (!ret) {
RTMP_Free(rtmp);
return -2;
}
if (isPublishMode) {
RTMP_EnableWrite(rtmp);
}
ret = RTMP_Connect(rtmp, NULL);
if (!ret) {
RTMP_Free(rtmp);
return -3;
}
ret = RTMP_ConnectStream(rtmp, 0);
if (!ret) {
return -4;
}
(*env)->ReleaseStringUTFChars(env, url_, url);
return 1;
}
示例5: rtmp_open
/**
* Open RTMP connection and verify that the stream can be played.
*
* URL syntax: rtmp://server[:port][/app][/playpath][ keyword=value]...
* where 'app' is first one or two directories in the path
* (e.g. /ondemand/, /flash/live/, etc.)
* and 'playpath' is a file name (the rest of the path,
* may be prefixed with "mp4:")
*
* Additional RTMP library options may be appended as
* space-separated key-value pairs.
*/
static int rtmp_open(URLContext *s, const char *uri, int flags)
{
LibRTMPContext *ctx = s->priv_data;
RTMP *r = &ctx->rtmp;
int rc = 0, level;
char *filename = s->filename;
switch (av_log_get_level()) {
default:
case AV_LOG_FATAL: level = RTMP_LOGCRIT; break;
case AV_LOG_ERROR: level = RTMP_LOGERROR; break;
case AV_LOG_WARNING: level = RTMP_LOGWARNING; break;
case AV_LOG_INFO: level = RTMP_LOGINFO; break;
case AV_LOG_VERBOSE: level = RTMP_LOGDEBUG; break;
case AV_LOG_DEBUG: level = RTMP_LOGDEBUG2; break;
}
RTMP_LogSetLevel(level);
RTMP_LogSetCallback(rtmp_log);
if (ctx->app || ctx->playpath) {
int len = strlen(s->filename) + 1;
if (ctx->app) len += strlen(ctx->app) + sizeof(" app=");
if (ctx->playpath) len += strlen(ctx->playpath) + sizeof(" playpath=");
if (!(filename = av_malloc(len)))
return AVERROR(ENOMEM);
av_strlcpy(filename, s->filename, len);
if (ctx->app) {
av_strlcat(filename, " app=", len);
av_strlcat(filename, ctx->app, len);
}
if (ctx->playpath) {
av_strlcat(filename, " playpath=", len);
av_strlcat(filename, ctx->playpath, len);
}
}
RTMP_Init(r);
if (!RTMP_SetupURL(r, filename)) {
rc = AVERROR_UNKNOWN;
goto fail;
}
if (flags & AVIO_FLAG_WRITE)
RTMP_EnableWrite(r);
if (!RTMP_Connect(r, NULL) || !RTMP_ConnectStream(r, 0)) {
rc = AVERROR_UNKNOWN;
goto fail;
}
s->is_streamed = 1;
rc = 0;
fail:
if (filename != s->filename)
av_freep(&filename);
return rc;
}
示例6: rtmp_open
/**
* Open RTMP connection and verify that the stream can be played.
*
* URL syntax: rtmp://server[:port][/app][/playpath][ keyword=value]...
* where 'app' is first one or two directories in the path
* (e.g. /ondemand/, /flash/live/, etc.)
* and 'playpath' is a file name (the rest of the path,
* may be prefixed with "mp4:")
*
* Additional RTMP library options may be appended as
* space-separated key-value pairs.
*/
static int rtmp_open(URLContext *s, const char *uri, int flags)
{
RTMP *r;
int rc;
r = av_mallocz(sizeof(RTMP));
if (!r)
return AVERROR(ENOMEM);
switch (av_log_get_level())
{
default:
case AV_LOG_FATAL:
rc = RTMP_LOGCRIT;
break;
case AV_LOG_ERROR:
rc = RTMP_LOGERROR;
break;
case AV_LOG_WARNING:
rc = RTMP_LOGWARNING;
break;
case AV_LOG_INFO:
rc = RTMP_LOGINFO;
break;
case AV_LOG_VERBOSE:
rc = RTMP_LOGDEBUG;
break;
case AV_LOG_DEBUG:
rc = RTMP_LOGDEBUG2;
break;
}
RTMP_LogSetLevel(rc);
RTMP_LogSetCallback(rtmp_log);
RTMP_Init(r);
if (!RTMP_SetupURL(r, s->filename))
{
rc = -1;
goto fail;
}
if (flags & AVIO_WRONLY)
RTMP_EnableWrite(r);
if (!RTMP_Connect(r, NULL) || !RTMP_ConnectStream(r, 0))
{
rc = -1;
goto fail;
}
s->priv_data = r;
s->is_streamed = 1;
return 0;
fail:
av_free(r);
return rc;
}
示例7: rtmp_playvideo
static event_t *
rtmp_playvideo(const char *url0, media_pipe_t *mp,
int flags, int priority,
char *errbuf, size_t errlen,
const char *mimetype)
{
rtmp_t r = {0};
event_t *e;
char *url = mystrdupa(url0);
prop_set_string(mp->mp_prop_type, "video");
RTMP_LogSetLevel(RTMP_LOGINFO);
r.r = RTMP_Alloc();
RTMP_Init(r.r);
if(!RTMP_SetupURL(r.r, url)) {
snprintf(errbuf, errlen, "Unable to setup RTMP-session");
rtmp_free(&r);
return NULL;
}
if(!RTMP_Connect(r.r, NULL)) {
snprintf(errbuf, errlen, "Unable to connect RTMP-session");
rtmp_free(&r);
return NULL;
}
if(!RTMP_ConnectStream(r.r, 0)) {
snprintf(errbuf, errlen, "Unable to connect RTMP-stream");
rtmp_free(&r);
return NULL;
}
mp->mp_audio.mq_stream = 0;
mp->mp_video.mq_stream = 0;
mp_configure(mp, MP_PLAY_CAPS_PAUSE, MP_BUFFER_DEEP);
mp->mp_max_realtime_delay = (r.r->Link.timeout - 1) * 1000000;
mp_become_primary(mp);
e = rtmp_loop(&r, mp, url, errbuf, errlen);
mp_flush(mp, 0);
mp_shutdown(mp);
TRACE(TRACE_DEBUG, "RTMP", "End of stream");
rtmp_free(&r);
return e;
}
示例8: main
int main(int argc, char **argv)
{
RTMP *rtmp=RTMP_Alloc();
if(!rtmp)
return 1;
RTMP_Init(rtmp);
RTMP_Free(rtmp);
return 0;
}
示例9: gst_rtmp_src_start
/* open the file, do stuff necessary to go to PAUSED state */
static gboolean
gst_rtmp_src_start (GstBaseSrc * basesrc)
{
GstRTMPSrc *src;
src = GST_RTMP_SRC (basesrc);
if (!src->uri) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), ("No filename given"));
return FALSE;
}
src->cur_offset = 0;
src->last_timestamp = 0;
src->discont = TRUE;
src->rtmp = RTMP_Alloc ();
if (!src->rtmp) {
GST_ERROR_OBJECT (src, "Could not allocate librtmp's RTMP context");
goto error;
}
RTMP_Init (src->rtmp);
if (!RTMP_SetupURL (src->rtmp, src->uri)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Failed to setup URL '%s'", src->uri));
goto error;
}
src->seekable = !(src->rtmp->Link.lFlags & RTMP_LF_LIVE);
GST_INFO_OBJECT (src, "seekable %d", src->seekable);
/* open if required */
if (!RTMP_IsConnected (src->rtmp)) {
if (!RTMP_Connect (src->rtmp, NULL)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Could not connect to RTMP stream \"%s\" for reading", src->uri));
goto error;
}
}
return TRUE;
error:
if (src->rtmp) {
RTMP_Free (src->rtmp);
src->rtmp = NULL;
}
return FALSE;
}
示例10: rtmp_setup_connection
static CURLcode rtmp_setup_connection(struct connectdata *conn)
{
RTMP *r = RTMP_Alloc();
if(!r)
return CURLE_OUT_OF_MEMORY;
RTMP_Init(r);
RTMP_SetBufferMS(r, DEF_BUFTIME);
if(!RTMP_SetupURL(r, conn->data->change.url)) {
RTMP_Free(r);
return CURLE_URL_MALFORMAT;
}
conn->proto.generic = r;
return CURLE_OK;
}
示例11: ll
int CRtmpdSession::Init( sqbind::CSqSocket *pSocket )
{
oexAutoLock ll( _g_rtmpd_lock );
if ( !ll.IsLocked() ) return 0;
// Out with the old
Destroy();
#if _DEBUG
// Unfortunately, this is a must for the debug version
if ( !netstackdump || !netstackdump_read )
{ setLastErrorStr( "You must call StartDebugLog() in debug versions" );
return 0;
} // end if
#endif
// Sanity check
if ( !pSocket || !pSocket->Ptr() )
{ setLastErrorStr( "Invalid socket" );
return 0;
} // end if
// Initialize the session object
RTMP_Init( &m_session );
// Mark stream as live
// m_session.Link.lFlags |= RTMP_LF_LIVE;
// Set short timeout
// m_session.Link.timeout = 15;
// Give the rtmpd object control of the socket handle
m_session.m_sb.sb_socket = oexPtrToInt( pSocket->Ptr()->Detach() );
// Disable Nagle's algorithm
int on = 1;
setsockopt( m_session.m_sb.sb_socket, IPPROTO_TCP, TCP_NODELAY, (char*)&on, sizeof( on ) );
// Attempt handshake
if ( !RTMP_Serve( &m_session ) )
{ setLastErrorStr( "RTMP handshake failed" );
return 0;
} // end if
return 1;
}
示例12: bzalloc
static void *rtmp_stream_create(obs_data_t *settings, obs_output_t *output)
{
struct rtmp_stream *stream = bzalloc(sizeof(struct rtmp_stream));
stream->output = output;
pthread_mutex_init_value(&stream->packets_mutex);
RTMP_Init(&stream->rtmp);
RTMP_LogSetCallback(log_rtmp);
RTMP_LogSetLevel(RTMP_LOGWARNING);
if (pthread_mutex_init(&stream->packets_mutex, NULL) != 0)
goto fail;
if (os_event_init(&stream->stop_event, OS_EVENT_TYPE_MANUAL) != 0)
goto fail;
if (pthread_mutex_init(&stream->write_buf_mutex, NULL) != 0) {
warn("Failed to initialize write buffer mutex");
goto fail;
}
if (os_event_init(&stream->buffer_space_available_event,
OS_EVENT_TYPE_AUTO) != 0) {
warn("Failed to initialize write buffer event");
goto fail;
}
if (os_event_init(&stream->buffer_has_data_event,
OS_EVENT_TYPE_AUTO) != 0) {
warn("Failed to initialize data buffer event");
goto fail;
}
if (os_event_init(&stream->socket_available_event,
OS_EVENT_TYPE_AUTO) != 0) {
warn("Failed to initialize socket buffer event");
goto fail;
}
if (os_event_init(&stream->send_thread_signaled_exit,
OS_EVENT_TYPE_MANUAL) != 0) {
warn("Failed to initialize socket exit event");
goto fail;
}
UNUSED_PARAMETER(settings);
return stream;
fail:
rtmp_stream_destroy(stream);
return NULL;
}
示例13: QObject
Rtmp::Rtmp(QUrl url, QObject *parent)
: QObject(parent)
{
m_rtmp = RTMP_Alloc();
RTMP_Init(m_rtmp);
qDebug() << "Connecting to" << url;
RTMP_SetupURL(m_rtmp, MY_URL );
RTMP_EnableWrite(m_rtmp);
RTMP_Connect(m_rtmp, NULL);
RTMP_ConnectStream(m_rtmp, 0);
memset(&m_rtmpPacket, 0, sizeof(RTMPPacket));
qDebug() << RTMP_IsConnected(m_rtmp);
}
示例14: gst_rtmp_src_start
/* open the file, do stuff necessary to go to PAUSED state */
static gboolean
gst_rtmp_src_start (GstBaseSrc * basesrc)
{
GstRTMPSrc *src;
gchar *uri_copy;
src = GST_RTMP_SRC (basesrc);
if (!src->uri) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), ("No filename given"));
return FALSE;
}
src->cur_offset = 0;
src->last_timestamp = 0;
src->seekable = TRUE;
src->discont = TRUE;
uri_copy = g_strdup (src->uri);
src->rtmp = RTMP_Alloc ();
RTMP_Init (src->rtmp);
if (!RTMP_SetupURL (src->rtmp, uri_copy)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Failed to setup URL '%s'", src->uri));
g_free (uri_copy);
RTMP_Free (src->rtmp);
src->rtmp = NULL;
return FALSE;
}
/* open if required */
if (!RTMP_IsConnected (src->rtmp)) {
if (!RTMP_Connect (src->rtmp, NULL)) {
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL),
("Could not connect to RTMP stream \"%s\" for reading", src->uri));
RTMP_Free (src->rtmp);
src->rtmp = NULL;
return FALSE;
}
}
return TRUE;
}
示例15: fopen
LibRtmp::LibRtmp(bool isNeedLog, bool isNeedRecord)
{
if (isNeedLog)
{
flog_ = fopen("librtmp.log", "w");
RTMP_LogSetLevel(RTMP_LOGDEBUG2);
RTMP_LogSetOutput(flog_);
}
else
{
flog_ = NULL;
}
rtmp_ = RTMP_Alloc();
RTMP_Init(rtmp_);
RTMP_SetBufferMS(rtmp_, 300);
streming_url_ = NULL;
is_need_record_ = isNeedRecord;
}