Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "base/basictypes.h" |
michael@0 | 6 | #include "mozilla/ClearOnShutdown.h" |
michael@0 | 7 | #include "StreamingProtocolService.h" |
michael@0 | 8 | #include "mozilla/net/NeckoChild.h" |
michael@0 | 9 | #include "nsIURI.h" |
michael@0 | 10 | #include "necko-config.h" |
michael@0 | 11 | |
michael@0 | 12 | #ifdef NECKO_PROTOCOL_rtsp |
michael@0 | 13 | #include "RtspControllerChild.h" |
michael@0 | 14 | #include "RtspController.h" |
michael@0 | 15 | #endif |
michael@0 | 16 | |
michael@0 | 17 | namespace mozilla { |
michael@0 | 18 | namespace net { |
michael@0 | 19 | |
michael@0 | 20 | NS_IMPL_ISUPPORTS(StreamingProtocolControllerService, |
michael@0 | 21 | nsIStreamingProtocolControllerService) |
michael@0 | 22 | |
michael@0 | 23 | /* static */ |
michael@0 | 24 | StaticRefPtr<StreamingProtocolControllerService> sSingleton; |
michael@0 | 25 | |
michael@0 | 26 | /* static */ |
michael@0 | 27 | already_AddRefed<StreamingProtocolControllerService> |
michael@0 | 28 | StreamingProtocolControllerService::GetInstance() |
michael@0 | 29 | { |
michael@0 | 30 | if (!sSingleton) { |
michael@0 | 31 | sSingleton = new StreamingProtocolControllerService(); |
michael@0 | 32 | ClearOnShutdown(&sSingleton); |
michael@0 | 33 | } |
michael@0 | 34 | nsRefPtr<StreamingProtocolControllerService> service = sSingleton.get(); |
michael@0 | 35 | return service.forget(); |
michael@0 | 36 | } |
michael@0 | 37 | |
michael@0 | 38 | NS_IMETHODIMP |
michael@0 | 39 | StreamingProtocolControllerService::Create(nsIChannel *aChannel, nsIStreamingProtocolController **aResult) |
michael@0 | 40 | { |
michael@0 | 41 | nsRefPtr<nsIStreamingProtocolController> mediacontroller; |
michael@0 | 42 | nsCOMPtr<nsIURI> uri; |
michael@0 | 43 | nsAutoCString scheme; |
michael@0 | 44 | |
michael@0 | 45 | NS_ENSURE_ARG_POINTER(aChannel); |
michael@0 | 46 | aChannel->GetURI(getter_AddRefs(uri)); |
michael@0 | 47 | |
michael@0 | 48 | nsresult rv = uri->GetScheme(scheme); |
michael@0 | 49 | if (NS_FAILED(rv)) return rv; |
michael@0 | 50 | |
michael@0 | 51 | #ifdef NECKO_PROTOCOL_rtsp |
michael@0 | 52 | if (scheme.EqualsLiteral("rtsp")) { |
michael@0 | 53 | if (IsNeckoChild()) { |
michael@0 | 54 | mediacontroller = new RtspControllerChild(aChannel); |
michael@0 | 55 | } else { |
michael@0 | 56 | mediacontroller = new RtspController(aChannel); |
michael@0 | 57 | } |
michael@0 | 58 | } |
michael@0 | 59 | #endif |
michael@0 | 60 | |
michael@0 | 61 | if (!mediacontroller) { |
michael@0 | 62 | return NS_ERROR_NO_INTERFACE; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | mediacontroller->Init(uri); |
michael@0 | 66 | |
michael@0 | 67 | mediacontroller.forget(aResult); |
michael@0 | 68 | return NS_OK; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | } // namespace net |
michael@0 | 72 | } // namespace mozilla |