annotate librtmp.c @ 6262:7b8b71ff9a76 libavformat

Move SPACE_CHARS back to libavformat/internal.h It will be used by other parts of lavf now. This reverts svn rev 23846.
author mstorsjo
date Fri, 16 Jul 2010 14:12:52 +0000
parents 24d0c5dec55a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
1 /*
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
2 * RTMP network protocol
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
3 * Copyright (c) 2010 Howard Chu
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
4 *
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
5 * This file is part of FFmpeg.
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
6 *
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
11 *
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
15 * Lesser General Public License for more details.
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
16 *
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
20 */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
21
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
22 /**
5969
178de7695c6c Remove explicit filename from Doxygen @file commands.
diego
parents: 5963
diff changeset
23 * @file
5951
28103c669f01 whitespace cosmetics
diego
parents: 5904
diff changeset
24 * RTMP protocol based on http://rtmpdump.mplayerhq.hu/ librtmp
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
25 */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
26
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
27 #include "avformat.h"
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
28
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
29 #include <librtmp/rtmp.h>
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
30 #include <librtmp/log.h>
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
31
5952
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
32 static void rtmp_log(int level, const char *fmt, va_list args)
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
33 {
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
34 switch (level) {
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
35 default:
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
36 case RTMP_LOGCRIT: level = AV_LOG_FATAL; break;
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
37 case RTMP_LOGERROR: level = AV_LOG_ERROR; break;
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
38 case RTMP_LOGWARNING: level = AV_LOG_WARNING; break;
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
39 case RTMP_LOGINFO: level = AV_LOG_INFO; break;
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
40 case RTMP_LOGDEBUG: level = AV_LOG_VERBOSE; break;
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
41 case RTMP_LOGDEBUG2: level = AV_LOG_DEBUG; break;
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
42 }
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
43
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
44 av_vlog(NULL, level, fmt, args);
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
45 av_log(NULL, level, "\n");
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
46 }
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
47
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
48 static int rtmp_close(URLContext *s)
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
49 {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
50 RTMP *r = s->priv_data;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
51
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
52 RTMP_Close(r);
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
53 av_free(r);
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
54 return 0;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
55 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
56
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
57 /**
6199
fa244b4fe683 Fix grammar errors in documentation
mru
parents: 6068
diff changeset
58 * Open RTMP connection and verify that the stream can be played.
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
59 *
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
60 * URL syntax: rtmp://server[:port][/app][/playpath][ keyword=value]...
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
61 * where 'app' is first one or two directories in the path
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
62 * (e.g. /ondemand/, /flash/live/, etc.)
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
63 * and 'playpath' is a file name (the rest of the path,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
64 * may be prefixed with "mp4:")
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
65 *
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
66 * Additional RTMP library options may be appended as
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
67 * space-separated key-value pairs.
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
68 */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
69 static int rtmp_open(URLContext *s, const char *uri, int flags)
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
70 {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
71 RTMP *r;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
72 int rc;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
73
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
74 r = av_mallocz(sizeof(RTMP));
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
75 if (!r)
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
76 return AVERROR(ENOMEM);
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
77
5951
28103c669f01 whitespace cosmetics
diego
parents: 5904
diff changeset
78 switch (av_log_get_level()) {
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
79 default:
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
80 case AV_LOG_FATAL: rc = RTMP_LOGCRIT; break;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
81 case AV_LOG_ERROR: rc = RTMP_LOGERROR; break;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
82 case AV_LOG_WARNING: rc = RTMP_LOGWARNING; break;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
83 case AV_LOG_INFO: rc = RTMP_LOGINFO; break;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
84 case AV_LOG_VERBOSE: rc = RTMP_LOGDEBUG; break;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
85 case AV_LOG_DEBUG: rc = RTMP_LOGDEBUG2; break;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
86 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
87 RTMP_LogSetLevel(rc);
5952
7f9a0da9f56a Plug librtmp logging into av_log.
diego
parents: 5951
diff changeset
88 RTMP_LogSetCallback(rtmp_log);
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
89
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
90 RTMP_Init(r);
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
91 if (!RTMP_SetupURL(r, s->filename)) {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
92 rc = -1;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
93 goto fail;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
94 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
95
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
96 if (flags & URL_WRONLY)
6203
24d0c5dec55a Use new librtmp APIs instead of grubbing around in RTMP struct
hyc
parents: 6199
diff changeset
97 RTMP_EnableWrite(r);
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
98
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
99 if (!RTMP_Connect(r, NULL) || !RTMP_ConnectStream(r, 0)) {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
100 rc = -1;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
101 goto fail;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
102 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
103
5951
28103c669f01 whitespace cosmetics
diego
parents: 5904
diff changeset
104 s->priv_data = r;
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
105 s->is_streamed = 1;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
106 return 0;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
107 fail:
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
108 av_free(r);
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
109 return rc;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
110 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
111
6068
7fdda2416684 Declare the url_write buffer parameter as const
mstorsjo
parents: 5969
diff changeset
112 static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
113 {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
114 RTMP *r = s->priv_data;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
115
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
116 return RTMP_Write(r, buf, size);
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
117 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
118
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
119 static int rtmp_read(URLContext *s, uint8_t *buf, int size)
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
120 {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
121 RTMP *r = s->priv_data;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
122
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
123 return RTMP_Read(r, buf, size);
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
124 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
125
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
126 static int rtmp_read_pause(URLContext *s, int pause)
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
127 {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
128 RTMP *r = s->priv_data;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
129
6203
24d0c5dec55a Use new librtmp APIs instead of grubbing around in RTMP struct
hyc
parents: 6199
diff changeset
130 if (!RTMP_Pause(r, pause))
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
131 return -1;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
132 return 0;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
133 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
134
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
135 static int64_t rtmp_read_seek(URLContext *s, int stream_index,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
136 int64_t timestamp, int flags)
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
137 {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
138 RTMP *r = s->priv_data;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
139
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
140 if (flags & AVSEEK_FLAG_BYTE)
5962
e967aa2c1754 Prefer AVERROR(ENOSYS) over AVERROR_NOTSUPP.
stefano
parents: 5952
diff changeset
141 return AVERROR(ENOSYS);
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
142
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
143 /* seeks are in milliseconds */
5963
12bdd63f5259 Implement librtmp seek support.
stefano
parents: 5962
diff changeset
144 if (stream_index < 0)
12bdd63f5259 Implement librtmp seek support.
stefano
parents: 5962
diff changeset
145 timestamp = av_rescale_rnd(timestamp, 1000, AV_TIME_BASE,
12bdd63f5259 Implement librtmp seek support.
stefano
parents: 5962
diff changeset
146 flags & AVSEEK_FLAG_BACKWARD ? AV_ROUND_DOWN : AV_ROUND_UP);
12bdd63f5259 Implement librtmp seek support.
stefano
parents: 5962
diff changeset
147
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
148 if (!RTMP_SendSeek(r, timestamp))
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
149 return -1;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
150 return timestamp;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
151 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
152
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
153 static int rtmp_get_file_handle(URLContext *s)
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
154 {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
155 RTMP *r = s->priv_data;
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
156
6203
24d0c5dec55a Use new librtmp APIs instead of grubbing around in RTMP struct
hyc
parents: 6199
diff changeset
157 return RTMP_Socket(r);
5904
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
158 }
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
159
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
160 URLProtocol rtmp_protocol = {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
161 "rtmp",
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
162 rtmp_open,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
163 rtmp_read,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
164 rtmp_write,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
165 NULL, /* seek */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
166 rtmp_close,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
167 NULL, /* next */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
168 rtmp_read_pause,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
169 rtmp_read_seek,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
170 rtmp_get_file_handle
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
171 };
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
172
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
173 URLProtocol rtmpt_protocol = {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
174 "rtmpt",
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
175 rtmp_open,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
176 rtmp_read,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
177 rtmp_write,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
178 NULL, /* seek */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
179 rtmp_close,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
180 NULL, /* next */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
181 rtmp_read_pause,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
182 rtmp_read_seek,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
183 rtmp_get_file_handle
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
184 };
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
185
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
186 URLProtocol rtmpe_protocol = {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
187 "rtmpe",
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
188 rtmp_open,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
189 rtmp_read,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
190 rtmp_write,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
191 NULL, /* seek */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
192 rtmp_close,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
193 NULL, /* next */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
194 rtmp_read_pause,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
195 rtmp_read_seek,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
196 rtmp_get_file_handle
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
197 };
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
198
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
199 URLProtocol rtmpte_protocol = {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
200 "rtmpte",
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
201 rtmp_open,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
202 rtmp_read,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
203 rtmp_write,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
204 NULL, /* seek */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
205 rtmp_close,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
206 NULL, /* next */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
207 rtmp_read_pause,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
208 rtmp_read_seek,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
209 rtmp_get_file_handle
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
210 };
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
211
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
212 URLProtocol rtmps_protocol = {
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
213 "rtmps",
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
214 rtmp_open,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
215 rtmp_read,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
216 rtmp_write,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
217 NULL, /* seek */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
218 rtmp_close,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
219 NULL, /* next */
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
220 rtmp_read_pause,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
221 rtmp_read_seek,
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
222 rtmp_get_file_handle
5564d7f2ed5a Implement support to RTMP, RTMPT, RTMPE, RTMPTE, RTMPS protocols via
stefano
parents:
diff changeset
223 };