Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "base/basictypes.h"
6 #include "mozilla/ClearOnShutdown.h"
7 #include "StreamingProtocolService.h"
8 #include "mozilla/net/NeckoChild.h"
9 #include "nsIURI.h"
10 #include "necko-config.h"
12 #ifdef NECKO_PROTOCOL_rtsp
13 #include "RtspControllerChild.h"
14 #include "RtspController.h"
15 #endif
17 namespace mozilla {
18 namespace net {
20 NS_IMPL_ISUPPORTS(StreamingProtocolControllerService,
21 nsIStreamingProtocolControllerService)
23 /* static */
24 StaticRefPtr<StreamingProtocolControllerService> sSingleton;
26 /* static */
27 already_AddRefed<StreamingProtocolControllerService>
28 StreamingProtocolControllerService::GetInstance()
29 {
30 if (!sSingleton) {
31 sSingleton = new StreamingProtocolControllerService();
32 ClearOnShutdown(&sSingleton);
33 }
34 nsRefPtr<StreamingProtocolControllerService> service = sSingleton.get();
35 return service.forget();
36 }
38 NS_IMETHODIMP
39 StreamingProtocolControllerService::Create(nsIChannel *aChannel, nsIStreamingProtocolController **aResult)
40 {
41 nsRefPtr<nsIStreamingProtocolController> mediacontroller;
42 nsCOMPtr<nsIURI> uri;
43 nsAutoCString scheme;
45 NS_ENSURE_ARG_POINTER(aChannel);
46 aChannel->GetURI(getter_AddRefs(uri));
48 nsresult rv = uri->GetScheme(scheme);
49 if (NS_FAILED(rv)) return rv;
51 #ifdef NECKO_PROTOCOL_rtsp
52 if (scheme.EqualsLiteral("rtsp")) {
53 if (IsNeckoChild()) {
54 mediacontroller = new RtspControllerChild(aChannel);
55 } else {
56 mediacontroller = new RtspController(aChannel);
57 }
58 }
59 #endif
61 if (!mediacontroller) {
62 return NS_ERROR_NO_INTERFACE;
63 }
65 mediacontroller->Init(uri);
67 mediacontroller.forget(aResult);
68 return NS_OK;
69 }
71 } // namespace net
72 } // namespace mozilla