rtmpproto: Don't mistake app for playpath.

For URLs "rtmp://server[:port]/foo" determine what `foo` refers to. If
application name has been defined by the user assume that `foo` is a
playpath, otherwise assume application name.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Kacper Michajłow 2014-10-19 18:16:17 +02:00 committed by Michael Niedermayer
parent 22cfa1f759
commit f22cf88fd3
1 changed files with 25 additions and 14 deletions

View File

@ -2594,7 +2594,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
{ {
RTMPContext *rt = s->priv_data; RTMPContext *rt = s->priv_data;
char proto[8], hostname[256], path[1024], auth[100], *fname; char proto[8], hostname[256], path[1024], auth[100], *fname;
char *old_app, *qmark, fname_buffer[1024]; char *old_app, *qmark, *n, fname_buffer[1024];
uint8_t buf[2048]; uint8_t buf[2048];
int port; int port;
AVDictionary *opts = NULL; AVDictionary *opts = NULL;
@ -2609,11 +2609,13 @@ static int rtmp_open(URLContext *s, const char *uri, int flags)
hostname, sizeof(hostname), &port, hostname, sizeof(hostname), &port,
path, sizeof(path), s->filename); path, sizeof(path), s->filename);
if (strchr(path, ' ')) { n = strchr(path, ' ');
if (n) {
av_log(s, AV_LOG_WARNING, av_log(s, AV_LOG_WARNING,
"Detected librtmp style URL parameters, these aren't supported " "Detected librtmp style URL parameters, these aren't supported "
"by the libavformat internal RTMP handler currently enabled. " "by the libavformat internal RTMP handler currently enabled. "
"See the documentation for the correct way to pass parameters.\n"); "See the documentation for the correct way to pass parameters.\n");
*n = '\0'; // Trim not supported part
} }
if (auth[0]) { if (auth[0]) {
@ -2712,8 +2714,14 @@ reconnect:
char *next = *path ? path + 1 : path; char *next = *path ? path + 1 : path;
char *p = strchr(next, '/'); char *p = strchr(next, '/');
if (!p) { if (!p) {
if (old_app) {
// If name of application has been defined by the user, assume that
// playpath is provided in the URL
fname = next; fname = next;
rt->app[0] = '\0'; } else {
fname = NULL;
av_strlcpy(rt->app, next, APP_MAX_LENGTH);
}
} else { } else {
// make sure we do not mismatch a playpath for an application instance // make sure we do not mismatch a playpath for an application instance
char *c = strchr(p + 1, ':'); char *c = strchr(p + 1, ':');
@ -2739,14 +2747,14 @@ reconnect:
} }
if (!rt->playpath) { if (!rt->playpath) {
int len = strlen(fname);
rt->playpath = av_malloc(PLAYPATH_MAX_LENGTH); rt->playpath = av_malloc(PLAYPATH_MAX_LENGTH);
if (!rt->playpath) { if (!rt->playpath) {
ret = AVERROR(ENOMEM); ret = AVERROR(ENOMEM);
goto fail; goto fail;
} }
if (fname) {
int len = strlen(fname);
if (!strchr(fname, ':') && len >= 4 && if (!strchr(fname, ':') && len >= 4 &&
(!strcmp(fname + len - 4, ".f4v") || (!strcmp(fname + len - 4, ".f4v") ||
!strcmp(fname + len - 4, ".mp4"))) { !strcmp(fname + len - 4, ".mp4"))) {
@ -2757,6 +2765,9 @@ reconnect:
rt->playpath[0] = 0; rt->playpath[0] = 0;
} }
av_strlcat(rt->playpath, fname, PLAYPATH_MAX_LENGTH); av_strlcat(rt->playpath, fname, PLAYPATH_MAX_LENGTH);
} else {
rt->playpath[0] = '\0';
}
} }
if (!rt->tcurl) { if (!rt->tcurl) {