Created
January 23, 2012 10:17
-
-
Save j0sh/1662333 to your computer and use it in GitHub Desktop.
RTMP: Enable application-specified clientids.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 9c3faeb2136528f72e496f7458b1feefbcc471ae Mon Sep 17 00:00:00 2001 | |
| From: Josh Allmann <joshua.allmann@gmail.com> | |
| Date: Mon, 23 Jan 2012 02:14:40 -0800 | |
| Subject: [PATCH] -- RTMP: Enable application-specified clientids. | |
| --- | |
| .../protocols/rtmp/basertmpappprotocolhandler.h | 8 ++++++++ | |
| .../rtmp/messagefactories/streammessagefactory.h | 16 ++++++++-------- | |
| .../rtmp/streaming/baseoutnetrtmpstream.h | 2 +- | |
| .../protocols/rtmp/streaming/innetrtmpstream.h | 2 +- | |
| .../protocols/rtmp/basertmpappprotocolhandler.cpp | 5 +++++ | |
| .../rtmp/messagefactories/streammessagefactory.cpp | 16 ++++++++-------- | |
| .../rtmp/streaming/baseoutnetrtmpstream.cpp | 2 ++ | |
| .../protocols/rtmp/streaming/innetrtmpstream.cpp | 6 +++++- | |
| 8 files changed, 38 insertions(+), 19 deletions(-) | |
| diff --git a/sources/thelib/include/protocols/rtmp/basertmpappprotocolhandler.h b/sources/thelib/include/protocols/rtmp/basertmpappprotocolhandler.h | |
| index e2138fa..6feb218 100644 | |
| --- a/sources/thelib/include/protocols/rtmp/basertmpappprotocolhandler.h | |
| +++ b/sources/thelib/include/protocols/rtmp/basertmpappprotocolhandler.h | |
| @@ -246,6 +246,14 @@ public: | |
| virtual BaseOutFileStream *CreateOutFileStream(BaseRTMPProtocol *pFrom, Variant &meta, bool append); | |
| /* | |
| + * Used to generate the 'clientid' parameter in RTMP streams. | |
| + * pFrom - connection responsible for the stream | |
| + * streamId - id of the stream | |
| + * clientid - clientid of the string object to set. | |
| + */ | |
| + virtual void GenerateClientId(BaseRTMPProtocol *pFrom, uint32_t streamId, Variant &clientid); | |
| + | |
| + /* | |
| * Create a file stream for writing to disk. | |
| * pFrom - The connection which wants to stream to disk | |
| * meta - Stream metadata | |
| diff --git a/sources/thelib/include/protocols/rtmp/messagefactories/streammessagefactory.h b/sources/thelib/include/protocols/rtmp/messagefactories/streammessagefactory.h | |
| index f462d55..c009da5 100644 | |
| --- a/sources/thelib/include/protocols/rtmp/messagefactories/streammessagefactory.h | |
| +++ b/sources/thelib/include/protocols/rtmp/messagefactories/streammessagefactory.h | |
| @@ -63,32 +63,32 @@ public: | |
| static Variant GetInvokeOnStatusStreamPublished(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| double requestId, string level, string code, string description, | |
| - string details, string clientId); | |
| + string details, Variant clientId); | |
| static Variant GetInvokeOnStatusStreamPlayFailed(Variant &request, | |
| string streamName); | |
| static Variant GetInvokeOnStatusStreamPlayFailed(uint32_t channelId, | |
| uint32_t streamId, double requestId, string streamName); | |
| static Variant GetInvokeOnStatusStreamPlayReset(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId); | |
| + double requestId, string description, string details, Variant clientId); | |
| static Variant GetInvokeOnStatusStreamPlayStart(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId); | |
| + double requestId, string description, string details, Variant clientId); | |
| static Variant GetInvokeOnStatusStreamPlayStop(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId); | |
| + double requestId, string description, string details, Variant clientId); | |
| static Variant GetInvokeOnStatusStreamPlayUnpublishNotify(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string clientId); | |
| + double requestId, string description, Variant clientId); | |
| static Variant GetInvokeOnStatusStreamSeekNotify(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId); | |
| + double requestId, string description, string details, Variant clientId); | |
| static Variant GetInvokeOnStatusStreamPauseNotify(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId); | |
| + double requestId, string description, string details, Variant clientId); | |
| static Variant GetInvokeOnStatusStreamUnpauseNotify(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId); | |
| + double requestId, string description, string details, Variant clientId); | |
| static Variant GetNotifyRtmpSampleAccess(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| bool unknown1, bool unknown2); | |
| diff --git a/sources/thelib/include/protocols/rtmp/streaming/baseoutnetrtmpstream.h b/sources/thelib/include/protocols/rtmp/streaming/baseoutnetrtmpstream.h | |
| index 3552da7..0b63308 100644 | |
| --- a/sources/thelib/include/protocols/rtmp/streaming/baseoutnetrtmpstream.h | |
| +++ b/sources/thelib/include/protocols/rtmp/streaming/baseoutnetrtmpstream.h | |
| @@ -59,7 +59,7 @@ private: | |
| uint32_t _maxBufferSize; | |
| uint64_t _attachedStreamType; | |
| Variant _completeMetadata; | |
| - string _clientId; | |
| + Variant _clientId; | |
| bool _paused; | |
| bool _sendOnStatusPlayMessages; | |
| diff --git a/sources/thelib/include/protocols/rtmp/streaming/innetrtmpstream.h b/sources/thelib/include/protocols/rtmp/streaming/innetrtmpstream.h | |
| index 50f08e3..b5fa144 100644 | |
| --- a/sources/thelib/include/protocols/rtmp/streaming/innetrtmpstream.h | |
| +++ b/sources/thelib/include/protocols/rtmp/streaming/innetrtmpstream.h | |
| @@ -35,7 +35,7 @@ private: | |
| uint32_t _rtmpStreamId; | |
| uint32_t _chunkSize; | |
| uint32_t _channelId; | |
| - string _clientId; | |
| + Variant _clientId; | |
| IOBuffer _videoCodecInit; | |
| double _lastVideoTime; | |
| IOBuffer _audioCodecInit; | |
| diff --git a/sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp b/sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp | |
| index 6d2eedd..c206bd7 100644 | |
| --- a/sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp | |
| +++ b/sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp | |
| @@ -1901,6 +1901,11 @@ string NormalizeStreamName(string streamName) { | |
| return streamName; | |
| } | |
| +void BaseRTMPAppProtocolHandler::GenerateClientId(BaseRTMPProtocol *pFrom, uint32_t streamId, Variant &clientid) | |
| +{ | |
| + clientid = format("%d_%d_%"PRIz"u", pFrom->GetId(), streamId, (size_t)this); | |
| +} | |
| + | |
| bool BaseRTMPAppProtocolHandler::TryLinkToLiveStream(BaseRTMPProtocol *pFrom, | |
| uint32_t streamId, string streamName, bool &linked) { | |
| linked = false; | |
| diff --git a/sources/thelib/src/protocols/rtmp/messagefactories/streammessagefactory.cpp b/sources/thelib/src/protocols/rtmp/messagefactories/streammessagefactory.cpp | |
| index ee6c655..c60bc78 100644 | |
| --- a/sources/thelib/src/protocols/rtmp/messagefactories/streammessagefactory.cpp | |
| +++ b/sources/thelib/src/protocols/rtmp/messagefactories/streammessagefactory.cpp | |
| @@ -177,7 +177,7 @@ Variant StreamMessageFactory::GetInvokeOnStatusStreamPublishBadName(uint32_t cha | |
| Variant StreamMessageFactory::GetInvokeOnStatusStreamPublished(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| double requestId, string level, string code, string description, | |
| - string details, string clientId) { | |
| + string details, Variant clientId) { | |
| Variant result; | |
| result[RM_INVOKE_PARAMS_ONSTATUS_LEVEL] = level; | |
| @@ -215,7 +215,7 @@ Variant StreamMessageFactory::GetInvokeOnStatusStreamPlayFailed(uint32_t channel | |
| Variant StreamMessageFactory::GetInvokeOnStatusStreamPlayReset(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId) { | |
| + double requestId, string description, string details, Variant clientId) { | |
| Variant result; | |
| result[RM_INVOKE_PARAMS_ONSTATUS_LEVEL] = | |
| @@ -232,7 +232,7 @@ Variant StreamMessageFactory::GetInvokeOnStatusStreamPlayReset(uint32_t channelI | |
| Variant StreamMessageFactory::GetInvokeOnStatusStreamPlayStart(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId) { | |
| + double requestId, string description, string details, Variant clientId) { | |
| Variant result; | |
| result[RM_INVOKE_PARAMS_ONSTATUS_LEVEL] = | |
| @@ -249,7 +249,7 @@ Variant StreamMessageFactory::GetInvokeOnStatusStreamPlayStart(uint32_t channelI | |
| Variant StreamMessageFactory::GetInvokeOnStatusStreamPlayStop(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId) { | |
| + double requestId, string description, string details, Variant clientId) { | |
| Variant result; | |
| result[RM_INVOKE_PARAMS_ONSTATUS_LEVEL] = | |
| @@ -267,7 +267,7 @@ Variant StreamMessageFactory::GetInvokeOnStatusStreamPlayStop(uint32_t channelId | |
| Variant StreamMessageFactory::GetInvokeOnStatusStreamPlayUnpublishNotify(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string clientId) { | |
| + double requestId, string description, Variant clientId) { | |
| Variant result; | |
| result[RM_INVOKE_PARAMS_ONSTATUS_LEVEL] = | |
| @@ -283,7 +283,7 @@ Variant StreamMessageFactory::GetInvokeOnStatusStreamPlayUnpublishNotify(uint32_ | |
| Variant StreamMessageFactory::GetInvokeOnStatusStreamSeekNotify(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId) { | |
| + double requestId, string description, string details, Variant clientId) { | |
| Variant result; | |
| result[RM_INVOKE_PARAMS_ONSTATUS_LEVEL] = | |
| @@ -300,7 +300,7 @@ Variant StreamMessageFactory::GetInvokeOnStatusStreamSeekNotify(uint32_t channel | |
| Variant StreamMessageFactory::GetInvokeOnStatusStreamPauseNotify(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId) { | |
| + double requestId, string description, string details, Variant clientId) { | |
| Variant result; | |
| result[RM_INVOKE_PARAMS_ONSTATUS_LEVEL] = | |
| @@ -317,7 +317,7 @@ Variant StreamMessageFactory::GetInvokeOnStatusStreamPauseNotify(uint32_t channe | |
| Variant StreamMessageFactory::GetInvokeOnStatusStreamUnpauseNotify(uint32_t channelId, | |
| uint32_t streamId, double timeStamp, bool isAbsolute, | |
| - double requestId, string description, string details, string clientId) { | |
| + double requestId, string description, string details, Variant clientId) { | |
| Variant result; | |
| result[RM_INVOKE_PARAMS_ONSTATUS_LEVEL] = | |
| diff --git a/sources/thelib/src/protocols/rtmp/streaming/baseoutnetrtmpstream.cpp b/sources/thelib/src/protocols/rtmp/streaming/baseoutnetrtmpstream.cpp | |
| index 390668a..4116ac8 100644 | |
| --- a/sources/thelib/src/protocols/rtmp/streaming/baseoutnetrtmpstream.cpp | |
| +++ b/sources/thelib/src/protocols/rtmp/streaming/baseoutnetrtmpstream.cpp | |
| @@ -30,6 +30,8 @@ | |
| #include "protocols/liveflv/innetliveflvstream.h" | |
| #include "protocols/rtmp/streaming/outnetrtmp4rtmpstream.h" | |
| #include "protocols/rtmp/streaming/outnetrtmp4tsstream.h" | |
| +#include "protocols/rtmp/basertmpappprotocolhandler.h" | |
| +#include "application/baseclientapplication.h" | |
| //#define TRACK_HEADER(header,processed) if(processed==0) FINEST("%s",STR(header)); | |
| #define TRACK_HEADER(header,processed) | |
| diff --git a/sources/thelib/src/protocols/rtmp/streaming/innetrtmpstream.cpp b/sources/thelib/src/protocols/rtmp/streaming/innetrtmpstream.cpp | |
| index 6a2cf16..ebe48b8 100644 | |
| --- a/sources/thelib/src/protocols/rtmp/streaming/innetrtmpstream.cpp | |
| +++ b/sources/thelib/src/protocols/rtmp/streaming/innetrtmpstream.cpp | |
| @@ -25,6 +25,8 @@ | |
| #include "protocols/rtmp/streaming/baseoutnetrtmpstream.h" | |
| #include "protocols/rtmp/streaming/outfilertmpflvstream.h" | |
| #include "streaming/streamstypes.h" | |
| +#include "protocols/rtmp/basertmpappprotocolhandler.h" | |
| +#include "application/baseclientapplication.h" | |
| InNetRTMPStream::InNetRTMPStream(BaseRTMPProtocol *pProtocol, | |
| StreamsManager *pStreamsManager, string name, | |
| @@ -33,7 +35,9 @@ InNetRTMPStream::InNetRTMPStream(BaseRTMPProtocol *pProtocol, | |
| _rtmpStreamId = rtmpStreamId; | |
| _chunkSize = pProtocol->GetInboundChunkSize(); | |
| _channelId = channelId; | |
| - _clientId = format("%d_%d_%"PRIz"u", _pProtocol->GetId(), _rtmpStreamId, (size_t)this); | |
| + BaseRTMPAppProtocolHandler *handler = (BaseRTMPAppProtocolHandler*)pProtocol-> | |
| + GetApplication()->GetProtocolHandler(pProtocol); | |
| + handler->GenerateClientId((BaseRTMPProtocol*)pProtocol, _rtmpStreamId, _clientId); | |
| _lastVideoTime = 0; | |
| _lastAudioTime = 0; | |
| _pOutFileRTMPFLVStream = NULL; | |
| -- | |
| 1.7.5.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment