Skip to content

Rtmp appinst #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/re_fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ int pl_strcasecmp(const struct pl *pl, const char *str);
int pl_cmp(const struct pl *pl1, const struct pl *pl2);
int pl_casecmp(const struct pl *pl1, const struct pl *pl2);
const char *pl_strchr(const struct pl *pl, char c);
const char *pl_strrchr(const struct pl *pl, char c);

/** Advance pl position/length by +/- N bytes */
static inline void pl_advance(struct pl *pl, ssize_t n)
Expand Down
25 changes: 25 additions & 0 deletions src/fmt/pl.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,28 @@ const char *pl_strchr(const struct pl *pl, char c)

return NULL;
}


/**
* Locate the last occurrence of character in pointer-length string
*
* @param pl Pointer-length string
* @param c Character to locate
*
* @return Pointer to last char if found, otherwise NULL
*/
const char *pl_strrchr(const struct pl *pl, char c)
{
const char *p, *end;

if (!pl_isset(pl))
return NULL;

end = pl->p + pl->l - 1;
for (p = end; p >= pl->p; p--) {
if (*p == c)
return p;
}

return NULL;
}
18 changes: 15 additions & 3 deletions src/rtmp/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ static int send_connect(struct rtmp_conn *conn)
1,
RTMP_AMF_TYPE_OBJECT, 8,
RTMP_AMF_TYPE_STRING, "app", conn->app,
RTMP_AMF_TYPE_STRING, "flashVer", "LNX 9,0,124,2",
RTMP_AMF_TYPE_STRING, "flashVer", "FMLE/3.0",
RTMP_AMF_TYPE_STRING, "tcUrl", conn->uri,
RTMP_AMF_TYPE_BOOLEAN, "fpad", false,
RTMP_AMF_TYPE_NUMBER, "capabilities", 15.0,
Expand Down Expand Up @@ -803,18 +803,30 @@ int rtmp_connect(struct rtmp_conn **connp, struct dnsc *dnsc, const char *uri,
struct pl pl_hostport;
struct pl pl_host;
struct pl pl_port;
struct pl pl_path;
struct pl pl_app;
struct pl pl_stream;
const char *tok;
uint16_t defport;
int err;

if (!connp || !uri)
return EINVAL;

if (re_regex(uri, strlen(uri), "[a-z]+://[^/]+/[^/]+/[^]+",
&pl_scheme, &pl_hostport, &pl_app, &pl_stream))
if (re_regex(uri, strlen(uri), "[a-z]+://[^/]+/[^]+",
&pl_scheme, &pl_hostport, &pl_path))
return EINVAL;

tok = pl_strrchr(&pl_path, '/');
if (!tok)
return EINVAL;

pl_app.p = pl_path.p;
pl_app.l = tok - pl_path.p;

pl_stream.p = tok + 1;
pl_stream.l = pl_path.p + pl_path.l - pl_stream.p;

if (!pl_strcasecmp(&pl_scheme, "rtmp")) {
tls = NULL;
defport = RTMP_PORT;
Expand Down