michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "base/basictypes.h" michael@0: #include "mozilla/ClearOnShutdown.h" michael@0: #include "StreamingProtocolService.h" michael@0: #include "mozilla/net/NeckoChild.h" michael@0: #include "nsIURI.h" michael@0: #include "necko-config.h" michael@0: michael@0: #ifdef NECKO_PROTOCOL_rtsp michael@0: #include "RtspControllerChild.h" michael@0: #include "RtspController.h" michael@0: #endif michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: NS_IMPL_ISUPPORTS(StreamingProtocolControllerService, michael@0: nsIStreamingProtocolControllerService) michael@0: michael@0: /* static */ michael@0: StaticRefPtr sSingleton; michael@0: michael@0: /* static */ michael@0: already_AddRefed michael@0: StreamingProtocolControllerService::GetInstance() michael@0: { michael@0: if (!sSingleton) { michael@0: sSingleton = new StreamingProtocolControllerService(); michael@0: ClearOnShutdown(&sSingleton); michael@0: } michael@0: nsRefPtr service = sSingleton.get(); michael@0: return service.forget(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: StreamingProtocolControllerService::Create(nsIChannel *aChannel, nsIStreamingProtocolController **aResult) michael@0: { michael@0: nsRefPtr mediacontroller; michael@0: nsCOMPtr uri; michael@0: nsAutoCString scheme; michael@0: michael@0: NS_ENSURE_ARG_POINTER(aChannel); michael@0: aChannel->GetURI(getter_AddRefs(uri)); michael@0: michael@0: nsresult rv = uri->GetScheme(scheme); michael@0: if (NS_FAILED(rv)) return rv; michael@0: michael@0: #ifdef NECKO_PROTOCOL_rtsp michael@0: if (scheme.EqualsLiteral("rtsp")) { michael@0: if (IsNeckoChild()) { michael@0: mediacontroller = new RtspControllerChild(aChannel); michael@0: } else { michael@0: mediacontroller = new RtspController(aChannel); michael@0: } michael@0: } michael@0: #endif michael@0: michael@0: if (!mediacontroller) { michael@0: return NS_ERROR_NO_INTERFACE; michael@0: } michael@0: michael@0: mediacontroller->Init(uri); michael@0: michael@0: mediacontroller.forget(aResult); michael@0: return NS_OK; michael@0: } michael@0: michael@0: } // namespace net michael@0: } // namespace mozilla