mirror of https://bitbucket.org/ausocean/av.git
Merged in librtmpPorting (pull request #41)
LibrtmpPorting Approved-by: saxon.milton@gmail.com <saxon.milton@gmail.com>
This commit is contained in:
commit
d813a56ad6
|
@ -209,7 +209,7 @@ func (s *ffmpegSender) close() error {
|
|||
|
||||
// rtmpSender implements loadSender for a native RTMP destination.
|
||||
type rtmpSender struct {
|
||||
sess rtmp.Session
|
||||
sess *rtmp.Session
|
||||
|
||||
url string
|
||||
timeout uint
|
||||
|
@ -222,7 +222,7 @@ type rtmpSender struct {
|
|||
var _ restarter = (*rtmpSender)(nil)
|
||||
|
||||
func newRtmpSender(url string, timeout uint, retries int, log func(lvl, msg string)) (*rtmpSender, error) {
|
||||
var sess rtmp.Session
|
||||
var sess *rtmp.Session
|
||||
var err error
|
||||
for n := 0; n < retries; n++ {
|
||||
sess = rtmp.NewSession(url, timeout)
|
||||
|
|
4050
rtmp/rtmp.go
4050
rtmp/rtmp.go
File diff suppressed because it is too large
Load Diff
|
@ -70,16 +70,17 @@ extern "C"
|
|||
struct AMFObjectProperty *o_props;
|
||||
} AMFObject;
|
||||
|
||||
typedef struct P_vu {
|
||||
double p_number;
|
||||
AVal p_aval;
|
||||
AMFObject p_object;
|
||||
} P_vu;
|
||||
|
||||
typedef struct AMFObjectProperty
|
||||
{
|
||||
AVal p_name;
|
||||
AMFDataType p_type;
|
||||
union
|
||||
{
|
||||
double p_number;
|
||||
AVal p_aval;
|
||||
AMFObject p_object;
|
||||
} p_vu;
|
||||
P_vu p_vu;
|
||||
int16_t p_UTCoffset;
|
||||
} AMFObjectProperty;
|
||||
|
||||
|
|
|
@ -109,37 +109,37 @@ typedef enum {
|
|||
} RTMPTCmd;
|
||||
|
||||
static int DumpMetaData(AMFObject *obj);
|
||||
static int HandShake(RTMP *r, int FP9HandShake);
|
||||
static int SocksNegotiate(RTMP *r);
|
||||
int HandShake(RTMP *r, int FP9HandShake);
|
||||
int SocksNegotiate(RTMP *r);
|
||||
|
||||
static int SendConnectPacket(RTMP *r, RTMPPacket *cp);
|
||||
static int SendCheckBW(RTMP *r);
|
||||
static int SendCheckBWResult(RTMP *r, double txn);
|
||||
static int SendDeleteStream(RTMP *r, double dStreamId);
|
||||
static int SendFCSubscribe(RTMP *r, AVal *subscribepath);
|
||||
static int SendPlay(RTMP *r);
|
||||
static int SendBytesReceived(RTMP *r);
|
||||
static int SendUsherToken(RTMP *r, AVal *usherToken);
|
||||
int SendConnectPacket(RTMP *r, RTMPPacket *cp);
|
||||
int SendCheckBW(RTMP *r);
|
||||
int SendCheckBWResult(RTMP *r, double txn);
|
||||
int SendDeleteStream(RTMP *r, double dStreamId);
|
||||
int SendFCSubscribe(RTMP *r, AVal *subscribepath);
|
||||
int SendPlay(RTMP *r);
|
||||
int SendBytesReceived(RTMP *r);
|
||||
int SendUsherToken(RTMP *r, AVal *usherToken);
|
||||
|
||||
#if 0 /* unused */
|
||||
static int SendBGHasStream(RTMP *r, double dId, AVal *playpath);
|
||||
#endif
|
||||
|
||||
static int HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize);
|
||||
static int HandleMetadata(RTMP *r, char *body, unsigned int len);
|
||||
static void HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet);
|
||||
static void HandleAudio(RTMP *r, const RTMPPacket *packet);
|
||||
static void HandleVideo(RTMP *r, const RTMPPacket *packet);
|
||||
static void HandleCtrl(RTMP *r, const RTMPPacket *packet);
|
||||
static void HandleServerBW(RTMP *r, const RTMPPacket *packet);
|
||||
static void HandleClientBW(RTMP *r, const RTMPPacket *packet);
|
||||
int HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize);
|
||||
int HandleMetadata(RTMP *r, char *body, unsigned int len);
|
||||
void HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleAudio(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleVideo(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleCtrl(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleServerBW(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleClientBW(RTMP *r, const RTMPPacket *packet);
|
||||
|
||||
static int ReadN(RTMP *r, char *buffer, int n);
|
||||
static int WriteN(RTMP *r, const char *buffer, int n);
|
||||
int ReadN(RTMP *r, char *buffer, int n);
|
||||
int WriteN(RTMP *r, const char *buffer, int n);
|
||||
|
||||
static void DecodeTEA(AVal *key, AVal *text);
|
||||
void DecodeTEA(AVal *key, AVal *text);
|
||||
|
||||
static int HTTP_Post(RTMP *r, RTMPTCmd cmd, const char *buf, int len);
|
||||
int HTTP_Post(RTMP *r, RTMPTCmd cmd, const char *buf, int len);
|
||||
static int HTTP_read(RTMP *r, int fill);
|
||||
|
||||
static void CloseInternal(RTMP *r, int reconnect);
|
||||
|
@ -406,7 +406,7 @@ static const char DEFAULT_FLASH_VER[] = DEF_VERSTR;
|
|||
const AVal RTMP_DefaultFlashVer =
|
||||
{ (char *)DEFAULT_FLASH_VER, sizeof(DEFAULT_FLASH_VER) - 1 };
|
||||
|
||||
static void
|
||||
void
|
||||
SocksSetup(RTMP *r, AVal *sockshost)
|
||||
{
|
||||
if (sockshost->av_len)
|
||||
|
@ -866,7 +866,7 @@ int RTMP_SetupURL(RTMP *r, char *url)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
add_addr_info(struct sockaddr_in *service, AVal *host, int port)
|
||||
{
|
||||
char *hostname;
|
||||
|
@ -946,6 +946,7 @@ RTMP_Connect0(RTMP *r, struct sockaddr * service)
|
|||
if (setsockopt
|
||||
(r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv)))
|
||||
{
|
||||
printf("int here\n"); fflush(stdout);
|
||||
RTMP_Log(RTMP_LOGERROR, "%s, Setting socket timeout to %ds failed!",
|
||||
__FUNCTION__, r->Link.timeout);
|
||||
}
|
||||
|
@ -1058,8 +1059,7 @@ RTMP_Connect(RTMP *r, RTMPPacket *cp)
|
|||
return RTMP_Connect1(r, cp);
|
||||
}
|
||||
|
||||
static int
|
||||
SocksNegotiate(RTMP *r)
|
||||
int SocksNegotiate(RTMP *r)
|
||||
{
|
||||
unsigned long addr;
|
||||
struct sockaddr_in service;
|
||||
|
@ -1386,7 +1386,7 @@ extern FILE *netstackdump;
|
|||
extern FILE *netstackdump_read;
|
||||
#endif
|
||||
|
||||
static int
|
||||
int
|
||||
ReadN(RTMP *r, char *buffer, int n)
|
||||
{
|
||||
int nOriginalSize = n;
|
||||
|
@ -1498,7 +1498,7 @@ ReadN(RTMP *r, char *buffer, int n)
|
|||
return nOriginalSize - n;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
WriteN(RTMP *r, const char *buffer, int n)
|
||||
{
|
||||
const char *ptr = buffer;
|
||||
|
@ -1575,7 +1575,7 @@ SAVC(secureTokenResponse);
|
|||
SAVC(type);
|
||||
SAVC(nonprivate);
|
||||
|
||||
static int
|
||||
int
|
||||
SendConnectPacket(RTMP *r, RTMPPacket *cp)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -1748,7 +1748,7 @@ RTMP_SendCreateStream(RTMP *r)
|
|||
|
||||
SAVC(FCSubscribe);
|
||||
|
||||
static int
|
||||
int
|
||||
SendFCSubscribe(RTMP *r, AVal *subscribepath)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -1780,7 +1780,7 @@ SendFCSubscribe(RTMP *r, AVal *subscribepath)
|
|||
/* Justin.tv specific authentication */
|
||||
static const AVal av_NetStream_Authenticate_UsherToken = AVC("NetStream.Authenticate.UsherToken");
|
||||
|
||||
static int
|
||||
int
|
||||
SendUsherToken(RTMP *r, AVal *usherToken)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -1812,7 +1812,7 @@ SendUsherToken(RTMP *r, AVal *usherToken)
|
|||
|
||||
SAVC(releaseStream);
|
||||
|
||||
static int
|
||||
int
|
||||
SendReleaseStream(RTMP *r)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -1842,7 +1842,7 @@ SendReleaseStream(RTMP *r)
|
|||
|
||||
SAVC(FCPublish);
|
||||
|
||||
static int
|
||||
int
|
||||
SendFCPublish(RTMP *r)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -1872,7 +1872,7 @@ SendFCPublish(RTMP *r)
|
|||
|
||||
SAVC(FCUnpublish);
|
||||
|
||||
static int
|
||||
int
|
||||
SendFCUnpublish(RTMP *r)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -1904,7 +1904,7 @@ SAVC(publish);
|
|||
SAVC(live);
|
||||
SAVC(record);
|
||||
|
||||
static int
|
||||
int
|
||||
SendPublish(RTMP *r)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -1939,7 +1939,7 @@ SendPublish(RTMP *r)
|
|||
|
||||
SAVC(deleteStream);
|
||||
|
||||
static int
|
||||
int
|
||||
SendDeleteStream(RTMP *r, double dStreamId)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -2076,7 +2076,7 @@ RTMP_SendClientBW(RTMP *r)
|
|||
return RTMP_SendPacket(r, &packet, FALSE);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
SendBytesReceived(RTMP *r)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -2101,7 +2101,7 @@ SendBytesReceived(RTMP *r)
|
|||
|
||||
SAVC(_checkbw);
|
||||
|
||||
static int
|
||||
int
|
||||
SendCheckBW(RTMP *r)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -2129,7 +2129,7 @@ SendCheckBW(RTMP *r)
|
|||
|
||||
SAVC(_result);
|
||||
|
||||
static int
|
||||
int
|
||||
SendCheckBWResult(RTMP *r, double txn)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -2158,7 +2158,7 @@ SendCheckBWResult(RTMP *r, double txn)
|
|||
SAVC(ping);
|
||||
SAVC(pong);
|
||||
|
||||
static int
|
||||
int
|
||||
SendPong(RTMP *r, double txn)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -2185,7 +2185,7 @@ SendPong(RTMP *r, double txn)
|
|||
|
||||
SAVC(play);
|
||||
|
||||
static int
|
||||
int
|
||||
SendPlay(RTMP *r)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -2253,7 +2253,7 @@ SendPlay(RTMP *r)
|
|||
SAVC(set_playlist);
|
||||
SAVC(0);
|
||||
|
||||
static int
|
||||
int
|
||||
SendPlaylist(RTMP *r)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -2291,7 +2291,7 @@ SendPlaylist(RTMP *r)
|
|||
return RTMP_SendPacket(r, &packet, TRUE);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
SendSecureTokenResponse(RTMP *r, AVal *resp)
|
||||
{
|
||||
RTMPPacket packet;
|
||||
|
@ -2389,7 +2389,7 @@ RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject, unsigned int nTime)
|
|||
return RTMP_SendPacket(r, &packet, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
AV_erase(RTMP_METHOD *vals, int *num, int i, int freeit)
|
||||
{
|
||||
if (freeit)
|
||||
|
@ -2410,7 +2410,7 @@ RTMP_DropRequest(RTMP *r, int i, int freeit)
|
|||
AV_erase(r->m_methodCalls, &r->m_numCalls, i, freeit);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
AV_queue(RTMP_METHOD **vals, int *num, AVal *av, int txn)
|
||||
{
|
||||
char *tmp;
|
||||
|
@ -2424,7 +2424,7 @@ AV_queue(RTMP_METHOD **vals, int *num, AVal *av, int txn)
|
|||
(*vals)[(*num)++].name.av_val = tmp;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
AV_clear(RTMP_METHOD *vals, int num)
|
||||
{
|
||||
int i;
|
||||
|
@ -2907,8 +2907,11 @@ static const AVal av_NetStream_Publish_Start = AVC("NetStream.Publish.Start");
|
|||
static const AVal av_NetConnection_Connect_Rejected =
|
||||
AVC("NetConnection.Connect.Rejected");
|
||||
|
||||
void sp(int n){
|
||||
printf("%d\n",n);fflush(stdout);
|
||||
}
|
||||
/* Returns 0 for OK/Failed/error, 1 for 'Stop or Complete' */
|
||||
static int
|
||||
int
|
||||
HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
||||
{
|
||||
AMFObject obj;
|
||||
|
@ -2917,6 +2920,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
int ret = 0, nRes;
|
||||
if (body[0] != 0x02) /* make sure it is a string method name we start with */
|
||||
{
|
||||
sp(1);
|
||||
RTMP_Log(RTMP_LOGWARNING, "%s, Sanity failed. no string method in invoke packet",
|
||||
__FUNCTION__);
|
||||
return 0;
|
||||
|
@ -2925,6 +2929,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
nRes = AMF_Decode(&obj, body, nBodySize, FALSE);
|
||||
if (nRes < 0)
|
||||
{
|
||||
sp(2);
|
||||
RTMP_Log(RTMP_LOGERROR, "%s, error decoding invoke packet", __FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2936,17 +2941,20 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
|
||||
if (AVMATCH(&method, &av__result))
|
||||
{
|
||||
sp(3);
|
||||
AVal methodInvoked = {0};
|
||||
int i;
|
||||
|
||||
for (i=0; i<r->m_numCalls; i++) {
|
||||
if (r->m_methodCalls[i].num == (int)txn) {
|
||||
sp(4);
|
||||
methodInvoked = r->m_methodCalls[i].name;
|
||||
AV_erase(r->m_methodCalls, &r->m_numCalls, i, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!methodInvoked.av_val) {
|
||||
sp(5);
|
||||
RTMP_Log(RTMP_LOGDEBUG, "%s, received result id %f without matching request",
|
||||
__FUNCTION__, txn);
|
||||
goto leave;
|
||||
|
@ -2957,22 +2965,27 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
|
||||
if (AVMATCH(&methodInvoked, &av_connect))
|
||||
{
|
||||
sp(6);
|
||||
if (r->Link.token.av_len)
|
||||
{
|
||||
sp(7);
|
||||
AMFObjectProperty p;
|
||||
if (RTMP_FindFirstMatchingProperty(&obj, &av_secureToken, &p))
|
||||
{
|
||||
sp(8);
|
||||
DecodeTEA(&r->Link.token, &p.p_vu.p_aval);
|
||||
SendSecureTokenResponse(r, &p.p_vu.p_aval);
|
||||
}
|
||||
}
|
||||
if (r->Link.protocol & RTMP_FEATURE_WRITE)
|
||||
{
|
||||
sp(9);
|
||||
SendReleaseStream(r);
|
||||
SendFCPublish(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
sp(10);
|
||||
RTMP_SendServerBW(r);
|
||||
RTMP_SendCtrl(r, 3, 0, 300);
|
||||
}
|
||||
|
@ -2980,6 +2993,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
|
||||
if (!(r->Link.protocol & RTMP_FEATURE_WRITE))
|
||||
{
|
||||
sp(11);
|
||||
/* Authenticate on Justin.tv legacy servers before sending FCSubscribe */
|
||||
if (r->Link.usherToken.av_len)
|
||||
SendUsherToken(r, &r->Link.usherToken);
|
||||
|
@ -2992,14 +3006,17 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
}
|
||||
else if (AVMATCH(&methodInvoked, &av_createStream))
|
||||
{
|
||||
sp(12);
|
||||
r->m_stream_id = (int)AMFProp_GetNumber(AMF_GetProp(&obj, NULL, 3));
|
||||
|
||||
if (r->Link.protocol & RTMP_FEATURE_WRITE)
|
||||
{
|
||||
sp(13);
|
||||
SendPublish(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
sp(14);
|
||||
if (r->Link.lFlags & RTMP_LF_PLST)
|
||||
SendPlaylist(r);
|
||||
SendPlay(r);
|
||||
|
@ -3009,44 +3026,53 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
else if (AVMATCH(&methodInvoked, &av_play) ||
|
||||
AVMATCH(&methodInvoked, &av_publish))
|
||||
{
|
||||
sp(15);
|
||||
r->m_bPlaying = TRUE;
|
||||
}
|
||||
free(methodInvoked.av_val);
|
||||
}
|
||||
else if (AVMATCH(&method, &av_onBWDone))
|
||||
{
|
||||
sp(16);
|
||||
if (!r->m_nBWCheckCounter)
|
||||
SendCheckBW(r);
|
||||
}
|
||||
else if (AVMATCH(&method, &av_onFCSubscribe))
|
||||
{
|
||||
sp(17);
|
||||
/* SendOnFCSubscribe(); */
|
||||
}
|
||||
else if (AVMATCH(&method, &av_onFCUnsubscribe))
|
||||
{
|
||||
sp(18);
|
||||
RTMP_Close(r);
|
||||
ret = 1;
|
||||
}
|
||||
else if (AVMATCH(&method, &av_ping))
|
||||
{
|
||||
sp(19);
|
||||
SendPong(r, txn);
|
||||
}
|
||||
else if (AVMATCH(&method, &av__onbwcheck))
|
||||
{
|
||||
sp(20);
|
||||
SendCheckBWResult(r, txn);
|
||||
}
|
||||
else if (AVMATCH(&method, &av__onbwdone))
|
||||
{
|
||||
sp(21);
|
||||
int i;
|
||||
for (i = 0; i < r->m_numCalls; i++)
|
||||
if (AVMATCH(&r->m_methodCalls[i].name, &av__checkbw))
|
||||
{
|
||||
sp(22);
|
||||
AV_erase(r->m_methodCalls, &r->m_numCalls, i, TRUE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (AVMATCH(&method, &av__error))
|
||||
{
|
||||
sp(23);
|
||||
#ifdef CRYPTO
|
||||
AVal methodInvoked = {0};
|
||||
int i;
|
||||
|
@ -3096,16 +3122,19 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
}
|
||||
free(methodInvoked.av_val);
|
||||
#else
|
||||
sp(24);
|
||||
RTMP_Log(RTMP_LOGERROR, "rtmp server sent error");
|
||||
#endif
|
||||
}
|
||||
else if (AVMATCH(&method, &av_close))
|
||||
{
|
||||
sp(25);
|
||||
RTMP_Log(RTMP_LOGERROR, "rtmp server requested close");
|
||||
RTMP_Close(r);
|
||||
}
|
||||
else if (AVMATCH(&method, &av_onStatus))
|
||||
{
|
||||
sp(26);
|
||||
AMFObject obj2;
|
||||
AVal code, level;
|
||||
AMFProp_GetObject(AMF_GetProp(&obj, NULL, 3), &obj2);
|
||||
|
@ -3118,6 +3147,7 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
|| AVMATCH(&code, &av_NetStream_Play_StreamNotFound)
|
||||
|| AVMATCH(&code, &av_NetConnection_Connect_InvalidApp))
|
||||
{
|
||||
sp(27);
|
||||
r->m_stream_id = -1;
|
||||
RTMP_Close(r);
|
||||
RTMP_Log(RTMP_LOGERROR, "Closing connection: %s", code.av_val);
|
||||
|
@ -3126,12 +3156,14 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
else if (AVMATCH(&code, &av_NetStream_Play_Start)
|
||||
|| AVMATCH(&code, &av_NetStream_Play_PublishNotify))
|
||||
{
|
||||
sp(28);
|
||||
int i;
|
||||
r->m_bPlaying = TRUE;
|
||||
for (i = 0; i < r->m_numCalls; i++)
|
||||
{
|
||||
if (AVMATCH(&r->m_methodCalls[i].name, &av_play))
|
||||
{
|
||||
sp(29);
|
||||
AV_erase(r->m_methodCalls, &r->m_numCalls, i, TRUE);
|
||||
break;
|
||||
}
|
||||
|
@ -3140,12 +3172,14 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
|
||||
else if (AVMATCH(&code, &av_NetStream_Publish_Start))
|
||||
{
|
||||
sp(30);
|
||||
int i;
|
||||
r->m_bPlaying = TRUE;
|
||||
for (i = 0; i < r->m_numCalls; i++)
|
||||
{
|
||||
if (AVMATCH(&r->m_methodCalls[i].name, &av_publish))
|
||||
{
|
||||
sp(31);
|
||||
AV_erase(r->m_methodCalls, &r->m_numCalls, i, TRUE);
|
||||
break;
|
||||
}
|
||||
|
@ -3157,19 +3191,23 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
|| AVMATCH(&code, &av_NetStream_Play_Stop)
|
||||
|| AVMATCH(&code, &av_NetStream_Play_UnpublishNotify))
|
||||
{
|
||||
sp(32);
|
||||
RTMP_Close(r);
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
else if (AVMATCH(&code, &av_NetStream_Seek_Notify))
|
||||
{
|
||||
sp(33);
|
||||
r->m_read.flags &= ~RTMP_READ_SEEKING;
|
||||
}
|
||||
|
||||
else if (AVMATCH(&code, &av_NetStream_Pause_Notify))
|
||||
{
|
||||
sp(34);
|
||||
if (r->m_pausing == 1 || r->m_pausing == 2)
|
||||
{
|
||||
sp(35);
|
||||
RTMP_SendPause(r, FALSE, r->m_pauseStamp);
|
||||
r->m_pausing = 3;
|
||||
}
|
||||
|
@ -3177,11 +3215,13 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
}
|
||||
else if (AVMATCH(&method, &av_playlist_ready))
|
||||
{
|
||||
sp(36);
|
||||
int i;
|
||||
for (i = 0; i < r->m_numCalls; i++)
|
||||
{
|
||||
if (AVMATCH(&r->m_methodCalls[i].name, &av_set_playlist))
|
||||
{
|
||||
sp(37);
|
||||
AV_erase(r->m_methodCalls, &r->m_numCalls, i, TRUE);
|
||||
break;
|
||||
}
|
||||
|
@ -3189,9 +3229,11 @@ HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize)
|
|||
}
|
||||
else
|
||||
{
|
||||
|
||||
sp(38);
|
||||
}
|
||||
sp(39);
|
||||
leave:
|
||||
sp(40);
|
||||
AMF_Reset(&obj);
|
||||
return ret;
|
||||
}
|
||||
|
@ -3299,7 +3341,7 @@ SAVC(duration);
|
|||
SAVC(video);
|
||||
SAVC(audio);
|
||||
|
||||
static int
|
||||
int
|
||||
HandleMetadata(RTMP *r, char *body, unsigned int len)
|
||||
{
|
||||
/* allright we get some info here, so parse it and print it */
|
||||
|
@ -3341,7 +3383,7 @@ HandleMetadata(RTMP *r, char *body, unsigned int len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet)
|
||||
{
|
||||
if (packet->m_nBodySize >= 4)
|
||||
|
@ -3352,17 +3394,17 @@ HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
HandleAudio(RTMP *r, const RTMPPacket *packet)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
HandleVideo(RTMP *r, const RTMPPacket *packet)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
HandleCtrl(RTMP *r, const RTMPPacket *packet)
|
||||
{
|
||||
short nType = -1;
|
||||
|
@ -3504,14 +3546,14 @@ HandleCtrl(RTMP *r, const RTMPPacket *packet)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
HandleServerBW(RTMP *r, const RTMPPacket *packet)
|
||||
{
|
||||
r->m_nServerBW = AMF_DecodeInt32(packet->m_body);
|
||||
RTMP_Log(RTMP_LOGDEBUG, "%s: server BW = %d", __FUNCTION__, r->m_nServerBW);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
HandleClientBW(RTMP *r, const RTMPPacket *packet)
|
||||
{
|
||||
r->m_nClientBW = AMF_DecodeInt32(packet->m_body);
|
||||
|
@ -3523,7 +3565,7 @@ HandleClientBW(RTMP *r, const RTMPPacket *packet)
|
|||
r->m_nClientBW2);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
DecodeInt32LE(const char *data)
|
||||
{
|
||||
unsigned char *c = (unsigned char *)data;
|
||||
|
@ -3533,7 +3575,7 @@ DecodeInt32LE(const char *data)
|
|||
return val;
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
EncodeInt32LE(char *output, int nVal)
|
||||
{
|
||||
output[0] = nVal;
|
||||
|
@ -3740,7 +3782,7 @@ RTMP_ReadPacket(RTMP *r, RTMPPacket *packet)
|
|||
}
|
||||
|
||||
#ifndef CRYPTO
|
||||
static int
|
||||
int
|
||||
HandShake(RTMP *r, int FP9HandShake)
|
||||
{
|
||||
int i;
|
||||
|
@ -4333,7 +4375,7 @@ RTMPSockBuf_Close(RTMPSockBuf *sb)
|
|||
|
||||
#define HEX2BIN(a) (((a)&0x40)?((a)&0xf)+9:((a)&0xf))
|
||||
|
||||
static void
|
||||
void
|
||||
DecodeTEA(AVal *key, AVal *text)
|
||||
{
|
||||
uint32_t *v, k[4] = { 0 }, u;
|
||||
|
@ -4403,7 +4445,7 @@ DecodeTEA(AVal *key, AVal *text)
|
|||
free(out);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
HTTP_Post(RTMP *r, RTMPTCmd cmd, const char *buf, int len)
|
||||
{
|
||||
char hbuf[512];
|
||||
|
|
|
@ -289,6 +289,25 @@ extern "C"
|
|||
void RTMP_SetBufferMS(RTMP *r, int size);
|
||||
void RTMP_UpdateBufferMS(RTMP *r);
|
||||
|
||||
void AV_clear(RTMP_METHOD *vals, int num);
|
||||
|
||||
void SocksSetup(RTMP *r, AVal *sockshost);
|
||||
int SocksNegotiate(RTMP *r);
|
||||
int SendFCUnpublish(RTMP *r);
|
||||
int HandShake(RTMP *r, int FP9HandShake);
|
||||
int DecodeInt32LE(const char *data);
|
||||
int SendBytesReceived(RTMP *r);
|
||||
int SendConnectPacket(RTMP *r, RTMPPacket *cp);
|
||||
int SendDeleteStream(RTMP *r, double dStreamId);
|
||||
int ReadN(RTMP *r, char *buffer, int n);
|
||||
int HandleInvoke(RTMP *r, const char *body, unsigned int nBodySize);
|
||||
int HandleMetadata(RTMP *r, char *body, unsigned int len);
|
||||
void HandleChangeChunkSize(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleAudio(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleVideo(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleCtrl(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleServerBW(RTMP *r, const RTMPPacket *packet);
|
||||
void HandleClientBW(RTMP *r, const RTMPPacket *packet);
|
||||
int RTMP_SetOpt(RTMP *r, const AVal *opt, AVal *arg);
|
||||
int RTMP_SetupURL(RTMP *r, char *url);
|
||||
void RTMP_SetupStream(RTMP *r, int protocol,
|
||||
|
@ -308,14 +327,19 @@ extern "C"
|
|||
AVal *usherToken,
|
||||
int dStart,
|
||||
int dStop, int bLiveStream, long int timeout);
|
||||
|
||||
int RTMP_Connect(RTMP *r, RTMPPacket *cp);
|
||||
struct sockaddr;
|
||||
int RTMP_Connect0(RTMP *r, struct sockaddr *svc);
|
||||
int RTMP_Connect1(RTMP *r, RTMPPacket *cp);
|
||||
int RTMP_Serve(RTMP *r);
|
||||
int RTMP_TLS_Accept(RTMP *r, void *ctx);
|
||||
|
||||
int SendCheckBW(RTMP *r);
|
||||
int SendCheckBWResult(RTMP *r, double txn);
|
||||
int SendDeleteStream(RTMP *r, double dStreamId);
|
||||
int SendFCSubscribe(RTMP *r, AVal *subscribepath);
|
||||
int SendPlay(RTMP *r);
|
||||
int SendBytesReceived(RTMP *r);
|
||||
int SendUsherToken(RTMP *r, AVal *usherToken);
|
||||
int RTMP_ReadPacket(RTMP *r, RTMPPacket *packet);
|
||||
int RTMP_SendPacket(RTMP *r, RTMPPacket *packet, int queue);
|
||||
int RTMP_SendChunk(RTMP *r, RTMPChunk *chunk);
|
||||
|
@ -324,25 +348,20 @@ extern "C"
|
|||
int RTMP_IsTimedout(RTMP *r);
|
||||
double RTMP_GetDuration(RTMP *r);
|
||||
int RTMP_ToggleStream(RTMP *r);
|
||||
|
||||
int RTMP_ConnectStream(RTMP *r, int seekTime);
|
||||
int RTMP_ReconnectStream(RTMP *r, int seekTime);
|
||||
void RTMP_DeleteStream(RTMP *r);
|
||||
int RTMP_GetNextMediaPacket(RTMP *r, RTMPPacket *packet);
|
||||
int RTMP_ClientPacket(RTMP *r, RTMPPacket *packet);
|
||||
|
||||
void RTMP_Init(RTMP *r);
|
||||
void RTMP_Close(RTMP *r);
|
||||
RTMP *RTMP_Alloc(void);
|
||||
void RTMP_Free(RTMP *r);
|
||||
void RTMP_EnableWrite(RTMP *r);
|
||||
|
||||
void *RTMP_TLS_AllocServerContext(const char* cert, const char* key);
|
||||
void RTMP_TLS_FreeServerContext(void *ctx);
|
||||
|
||||
int RTMP_LibVersion(void);
|
||||
void RTMP_UserInterrupt(void); /* user typed Ctrl-C */
|
||||
|
||||
int RTMP_SendCtrl(RTMP *r, short nType, unsigned int nObject,
|
||||
unsigned int nTime);
|
||||
|
||||
|
@ -351,14 +370,11 @@ extern "C"
|
|||
*/
|
||||
int RTMP_SendPause(RTMP *r, int DoPause, int dTime);
|
||||
int RTMP_Pause(RTMP *r, int DoPause);
|
||||
|
||||
int RTMP_FindFirstMatchingProperty(AMFObject *obj, const AVal *name,
|
||||
AMFObjectProperty * p);
|
||||
|
||||
int RTMPSockBuf_Fill(RTMPSockBuf *sb);
|
||||
int RTMPSockBuf_Send(RTMPSockBuf *sb, const char *buf, int len);
|
||||
int RTMPSockBuf_Close(RTMPSockBuf *sb);
|
||||
|
||||
int RTMP_SendCreateStream(RTMP *r);
|
||||
int RTMP_SendSeek(RTMP *r, int dTime);
|
||||
int RTMP_SendServerBW(RTMP *r);
|
||||
|
@ -366,7 +382,14 @@ extern "C"
|
|||
void RTMP_DropRequest(RTMP *r, int i, int freeit);
|
||||
int RTMP_Read(RTMP *r, char *buf, int size);
|
||||
int RTMP_Write(RTMP *r, const char *buf, int size);
|
||||
|
||||
void AV_erase(RTMP_METHOD *vals, int *num, int i, int freeit);
|
||||
void DecodeTEA(AVal *key, AVal *text);
|
||||
int SendFCPublish(RTMP *r);
|
||||
int SendPlaylist(RTMP *r);
|
||||
int SendPong(RTMP *r, double txn);
|
||||
int SendPublish(RTMP *r);
|
||||
int SendReleaseStream(RTMP *r);
|
||||
int SendSecureTokenResponse(RTMP *r, AVal *resp);
|
||||
/* hashswf.c */
|
||||
int RTMP_HashSWF(const char *url, unsigned int *size, unsigned char *hash,
|
||||
int age);
|
||||
|
|
Loading…
Reference in New Issue