Mercurial > libavformat.hg
comparison rtmpproto.c @ 5407:b7ef0aa415d0 libavformat
Move is_input flag into RTMP protocol context.
Patch by Sergiy (gmail(piratfm))
Thread "[PATCH] rtmp-output"
author | kostya |
---|---|
date | Wed, 02 Dec 2009 12:55:10 +0000 |
parents | 99aeb2e385df |
children | 1f27e6bd85c3 |
comparison
equal
deleted
inserted
replaced
5406:cef1f2baca9c | 5407:b7ef0aa415d0 |
---|---|
55 /** protocol handler context */ | 55 /** protocol handler context */ |
56 typedef struct RTMPContext { | 56 typedef struct RTMPContext { |
57 URLContext* stream; ///< TCP stream used in interactions with RTMP server | 57 URLContext* stream; ///< TCP stream used in interactions with RTMP server |
58 RTMPPacket prev_pkt[2][RTMP_CHANNELS]; ///< packet history used when reading and sending packets | 58 RTMPPacket prev_pkt[2][RTMP_CHANNELS]; ///< packet history used when reading and sending packets |
59 int chunk_size; ///< size of the chunks RTMP packets are divided into | 59 int chunk_size; ///< size of the chunks RTMP packets are divided into |
60 int is_input; ///< input/output flag | |
60 char playpath[256]; ///< path to filename to play (with possible "mp4:" prefix) | 61 char playpath[256]; ///< path to filename to play (with possible "mp4:" prefix) |
61 ClientState state; ///< current state | 62 ClientState state; ///< current state |
62 int main_channel_id; ///< an additional channel ID which is used for some invocations | 63 int main_channel_id; ///< an additional channel ID which is used for some invocations |
63 uint8_t* flv_data; ///< buffer with data for demuxer | 64 uint8_t* flv_data; ///< buffer with data for demuxer |
64 int flv_size; ///< current buffer size | 65 int flv_size; ///< current buffer size |
562 static int rtmp_open(URLContext *s, const char *uri, int flags) | 563 static int rtmp_open(URLContext *s, const char *uri, int flags) |
563 { | 564 { |
564 RTMPContext *rt; | 565 RTMPContext *rt; |
565 char proto[8], hostname[256], path[1024], app[128], *fname; | 566 char proto[8], hostname[256], path[1024], app[128], *fname; |
566 uint8_t buf[2048]; | 567 uint8_t buf[2048]; |
567 int port, is_input; | 568 int port; |
568 int ret; | 569 int ret; |
569 | |
570 is_input = !(flags & URL_WRONLY); | |
571 | 570 |
572 rt = av_mallocz(sizeof(RTMPContext)); | 571 rt = av_mallocz(sizeof(RTMPContext)); |
573 if (!rt) | 572 if (!rt) |
574 return AVERROR(ENOMEM); | 573 return AVERROR(ENOMEM); |
575 s->priv_data = rt; | 574 s->priv_data = rt; |
575 rt->is_input = !(flags & URL_WRONLY); | |
576 | 576 |
577 url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, | 577 url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), &port, |
578 path, sizeof(path), s->filename); | 578 path, sizeof(path), s->filename); |
579 | 579 |
580 if (port < 0) | 580 if (port < 0) |
584 if (url_open(&rt->stream, buf, URL_RDWR) < 0) { | 584 if (url_open(&rt->stream, buf, URL_RDWR) < 0) { |
585 av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot open connection %s\n", buf); | 585 av_log(LOG_CONTEXT, AV_LOG_ERROR, "Cannot open connection %s\n", buf); |
586 goto fail; | 586 goto fail; |
587 } | 587 } |
588 | 588 |
589 if (!is_input) { | 589 if (!rt->is_input) { |
590 av_log(LOG_CONTEXT, AV_LOG_ERROR, "RTMP output is not supported yet.\n"); | 590 av_log(LOG_CONTEXT, AV_LOG_ERROR, "RTMP output is not supported yet.\n"); |
591 goto fail; | 591 goto fail; |
592 } else { | 592 } else { |
593 rt->state = STATE_START; | 593 rt->state = STATE_START; |
594 if (rtmp_handshake(s, rt)) | 594 if (rtmp_handshake(s, rt)) |