Skip to content

Commit 927c9f7

Browse files
committed
1 parent 2af2b36 commit 927c9f7

File tree

6 files changed

+91
-12
lines changed

6 files changed

+91
-12
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
VERSION=v2.4
1+
VERSION=v2.4nl
22

3-
prefix=/usr/local
3+
prefix=
44

55
CC=$(CROSS_COMPILE)gcc
66
LD=$(CROSS_COMPILE)ld
@@ -35,7 +35,7 @@ MANDIR=$(DESTDIR)$(mandir)
3535
LIBS_posix=
3636
LIBS_darwin=
3737
LIBS_mingw=-lws2_32 -lwinmm -lgdi32
38-
LIB_RTMP=-Llibrtmp -lrtmp
38+
LIB_RTMP=-Llibrtmp -lrtmp
3939
LIBS=$(LIB_RTMP) $(CRYPTO_LIB) $(LIBS_$(SYS)) $(XLIBS)
4040

4141
THREADLIB_posix=-lpthread

librtmp/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
VERSION=v2.4
1+
VERSION=v2.4nl
22

3-
prefix=/usr/local
3+
prefix=
44

55
incdir=$(prefix)/include/librtmp
66
bindir=$(prefix)/bin

librtmp/rtmp.c

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,13 +446,19 @@ RTMP_SetupStream(RTMP *r,
446446
AVal *subscribepath,
447447
AVal *usherToken,
448448
int dStart,
449-
int dStop, int bLiveStream, long int timeout)
449+
int dStop, int bLiveStream, long int timeout,
450+
AVal *nlplaypath,
451+
AVal *nltoken,
452+
AVal *nlid)
450453
{
454+
RTMP_LogPrintf("Protocol : %s", RTMPProtocolStrings[protocol&7]);
451455
RTMP_Log(RTMP_LOGDEBUG, "Protocol : %s", RTMPProtocolStrings[protocol&7]);
452456
RTMP_Log(RTMP_LOGDEBUG, "Hostname : %.*s", host->av_len, host->av_val);
453457
RTMP_Log(RTMP_LOGDEBUG, "Port : %d", port);
454458
RTMP_Log(RTMP_LOGDEBUG, "Playpath : %s", playpath->av_val);
455459

460+
if (nlplaypath && nlplaypath->av_val)
461+
RTMP_Log(RTMP_LOGDEBUG, "nlplaypath : %s", nlplaypath->av_val);
456462
if (tcUrl && tcUrl->av_val)
457463
RTMP_Log(RTMP_LOGDEBUG, "tcUrl : %s", tcUrl->av_val);
458464
if (swfUrl && swfUrl->av_val)
@@ -476,6 +482,8 @@ RTMP_SetupStream(RTMP *r,
476482

477483
RTMP_Log(RTMP_LOGDEBUG, "live : %s", bLiveStream ? "yes" : "no");
478484
RTMP_Log(RTMP_LOGDEBUG, "timeout : %ld sec", timeout);
485+
RTMP_Log(RTMP_LOGDEBUG, "nltoken : %s", nltoken->av_val);
486+
RTMP_Log(RTMP_LOGDEBUG, "nlid : %s", nlid->av_val);
479487

480488
#ifdef CRYPTO
481489
if (swfSHA256Hash != NULL && swfSize > 0)
@@ -513,6 +521,12 @@ RTMP_SetupStream(RTMP *r,
513521
r->Link.flashVer = RTMP_DefaultFlashVer;
514522
if (subscribepath && subscribepath->av_len)
515523
r->Link.subscribepath = *subscribepath;
524+
if (nlplaypath && nlplaypath->av_len)
525+
r->Link.nlplaypath = *nlplaypath;
526+
if (nltoken && nltoken->av_len)
527+
r->Link.nltoken = *nltoken;
528+
if (nlid && nlid->av_len)
529+
r->Link.nlid = *nlid;
516530
if (usherToken && usherToken->av_len)
517531
r->Link.usherToken = *usherToken;
518532
r->Link.seekTime = dStart;
@@ -1743,6 +1757,38 @@ RTMP_SendCreateStream(RTMP *r)
17431757
return RTMP_SendPacket(r, &packet, TRUE);
17441758
}
17451759

1760+
SAVC(nlPlayNotice);
1761+
1762+
int
1763+
RTMP_SendNlplayNotice(RTMP *r, AVal *nlplaypath, AVal *nltoken, AVal *nlid)
1764+
{
1765+
RTMPPacket packet;
1766+
char pbuf[256], *pend = pbuf + sizeof(pbuf);
1767+
char *enc;
1768+
1769+
packet.m_nChannel = 0x03; /* control channel (invoke) */
1770+
packet.m_headerType = RTMP_PACKET_SIZE_MEDIUM;
1771+
packet.m_packetType = RTMP_PACKET_TYPE_INVOKE;
1772+
packet.m_nTimeStamp = 0;
1773+
packet.m_nInfoField2 = 0;
1774+
packet.m_hasAbsTimestamp = 0;
1775+
packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;
1776+
1777+
enc = packet.m_body;
1778+
enc = AMF_EncodeString(enc, pend, &av_nlPlayNotice);
1779+
enc = AMF_EncodeNumber(enc, pend, ++r->m_numInvokes);
1780+
*enc++ = AMF_NULL; /* NULL */
1781+
1782+
enc = AMF_EncodeString(enc, pend, nlplaypath);
1783+
enc = AMF_EncodeString(enc, pend, nltoken);
1784+
enc = AMF_EncodeString(enc, pend, nlid);
1785+
packet.m_nBodySize = enc - packet.m_body;
1786+
1787+
r->Link.playpath = *nlid;
1788+
1789+
return RTMP_SendPacket(r, &packet, TRUE);
1790+
}
1791+
17461792
SAVC(FCSubscribe);
17471793

17481794
static int
@@ -1759,7 +1805,7 @@ SendFCSubscribe(RTMP *r, AVal *subscribepath)
17591805
packet.m_hasAbsTimestamp = 0;
17601806
packet.m_body = pbuf + RTMP_MAX_HEADER_SIZE;
17611807

1762-
RTMP_Log(RTMP_LOGDEBUG, "FCSubscribe: %s", subscribepath->av_val);
1808+
RTMP_Log(RTMP_LOGDEBUG, "AAAAAAFCSubscribe: %s", subscribepath->av_val);
17631809
enc = packet.m_body;
17641810
enc = AMF_EncodeString(enc, pend, &av_FCSubscribe);
17651811
enc = AMF_EncodeNumber(enc, pend, ++r->m_numInvokes);
@@ -2954,6 +3000,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
29543000

29553001
if (AVMATCH(&methodInvoked, &av_connect))
29563002
{
3003+
29573004
if (r->Link.token.av_len)
29583005
{
29593006
AMFObjectProperty p;
@@ -2965,6 +3012,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
29653012
}
29663013
if (r->Link.protocol & RTMP_FEATURE_WRITE)
29673014
{
3015+
RTMP_Log(RTMP_LOGDEBUG, "Link.protocol %d", r->Link.protocol);
29683016
SendReleaseStream(r);
29693017
SendFCPublish(r);
29703018
}
@@ -2984,7 +3032,12 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
29843032
if (r->Link.subscribepath.av_len)
29853033
SendFCSubscribe(r, &r->Link.subscribepath);
29863034
else if (r->Link.lFlags & RTMP_LF_LIVE)
2987-
SendFCSubscribe(r, &r->Link.playpath);
3035+
{
3036+
if (r->Link.nlplaypath.av_len != 0)
3037+
RTMP_SendNlplayNotice(r, &r->Link.nlplaypath, &r->Link.nltoken, &r->Link.nlid);
3038+
else
3039+
SendFCSubscribe(r, &r->Link.playpath);
3040+
}
29883041
}
29893042
}
29903043
else if (AVMATCH(&methodInvoked, &av_createStream))

librtmp/rtmp.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ extern "C"
159159
AVal token;
160160
AVal pubUser;
161161
AVal pubPasswd;
162+
AVal nlplaypath;
163+
AVal nltoken;
164+
AVal nlid;
162165
AMFObject extras;
163166
int edepth;
164167

@@ -307,7 +310,10 @@ extern "C"
307310
AVal *subscribepath,
308311
AVal *usherToken,
309312
int dStart,
310-
int dStop, int bLiveStream, long int timeout);
313+
int dStop, int bLiveStream, long int timeout,
314+
AVal *nlplaypath,
315+
AVal *nltoken,
316+
AVal *nlid);
311317

312318
int RTMP_Connect(RTMP *r, RTMPPacket *cp);
313319
struct sockaddr;

rtmpdump.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,10 @@ main(int argc, char **argv)
774774
uint32_t swfSize = 0;
775775
AVal flashVer = { 0, 0 };
776776
AVal sockshost = { 0, 0 };
777+
AVal nlplaypath = { 0, 0 };
778+
AVal nltoken = { 0, 0 };
779+
AVal nlid = { 0, 0 };
780+
777781

778782
#ifdef CRYPTO
779783
int swfAge = 30; /* 30 days for SWF cache by default */
@@ -858,12 +862,13 @@ main(int argc, char **argv)
858862
{"quiet", 0, NULL, 'q'},
859863
{"verbose", 0, NULL, 'V'},
860864
{"jtv", 1, NULL, 'j'},
865+
{"nlplaypath", 1, NULL, 'N'},
861866
{0, 0, 0, 0}
862867
};
863868

864869
while ((opt =
865870
getopt_long(argc, argv,
866-
"hVveqzRr:s:t:i:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#j:",
871+
"hVveqzRr:s:t:i:p:a:b:f:o:u:C:n:c:l:y:Ym:k:d:A:B:T:w:x:W:X:S:#j:N:",
867872
longopts, NULL)) != -1)
868873
{
869874
switch (opt)
@@ -1069,6 +1074,7 @@ main(int argc, char **argv)
10691074
break;
10701075
case 'V':
10711076
RTMP_debuglevel = RTMP_LOGDEBUG;
1077+
RTMP_LogPrintf("change level %d\n", RTMP_debuglevel);
10721078
break;
10731079
case 'z':
10741080
RTMP_debuglevel = RTMP_LOGALL;
@@ -1079,6 +1085,18 @@ main(int argc, char **argv)
10791085
case 'j':
10801086
STR2AVAL(usherToken, optarg);
10811087
break;
1088+
case 'N':
1089+
{
1090+
char *tmp_nltoken;
1091+
char *tmp_nlid[255];
1092+
STR2AVAL(nlplaypath, strtok(optarg,","));
1093+
tmp_nltoken = strtok(NULL, ",");
1094+
STR2AVAL(nltoken , tmp_nltoken);
1095+
strcpy((char*)tmp_nlid, tmp_nltoken);
1096+
STR2AVAL(nlid , strtok((char*)tmp_nlid,"?"));
1097+
RTMP_Log(RTMP_LOGDEBUG, "nlplaypath: %s", optarg);
1098+
}
1099+
break;
10821100
default:
10831101
RTMP_LogPrintf("unknown option: %c\n", opt);
10841102
usage(argv[0]);
@@ -1198,7 +1216,8 @@ main(int argc, char **argv)
11981216
{
11991217
RTMP_SetupStream(&rtmp, protocol, &hostname, port, &sockshost, &playpath,
12001218
&tcUrl, &swfUrl, &pageUrl, &app, &auth, &swfHash, swfSize,
1201-
&flashVer, &subscribepath, &usherToken, dSeek, dStopOffset, bLiveStream, timeout);
1219+
&flashVer, &subscribepath, &usherToken, dSeek, dStopOffset, bLiveStream, timeout,
1220+
&nlplaypath, &nltoken, &nlid);
12021221
}
12031222
else
12041223
{

rtmpgw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,11 +553,12 @@ void processTCPrequest(STREAMING_SERVER * server, // server socket and state (ou
553553
RTMP_Log(RTMP_LOGDEBUG, "Setting buffer time to: %dms", req.bufferTime);
554554
RTMP_Init(&rtmp);
555555
RTMP_SetBufferMS(&rtmp, req.bufferTime);
556+
AVal a, b, c;
556557
if (!req.fullUrl.av_len)
557558
{
558559
RTMP_SetupStream(&rtmp, req.protocol, &req.hostname, req.rtmpport, &req.sockshost,
559560
&req.playpath, &req.tcUrl, &req.swfUrl, &req.pageUrl, &req.app, &req.auth, &req.swfHash, req.swfSize, &req.flashVer, &req.subscribepath, &req.usherToken, dSeek, req.dStopOffset,
560-
req.bLiveStream, req.timeout);
561+
req.bLiveStream, req.timeout, &a, &b, &c);
561562
}
562563
else
563564
{

0 commit comments

Comments
 (0)