Line data Source code
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/. */
4 :
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"
11 :
12 : #ifdef NECKO_PROTOCOL_rtsp
13 : #include "RtspControllerChild.h"
14 : #include "RtspController.h"
15 : #endif
16 :
17 : namespace mozilla {
18 : namespace net {
19 :
20 0 : NS_IMPL_ISUPPORTS(StreamingProtocolControllerService,
21 : nsIStreamingProtocolControllerService)
22 :
23 : /* static */
24 3 : StaticRefPtr<StreamingProtocolControllerService> sSingleton;
25 :
26 : /* static */
27 : already_AddRefed<StreamingProtocolControllerService>
28 0 : StreamingProtocolControllerService::GetInstance()
29 : {
30 0 : if (!sSingleton) {
31 0 : sSingleton = new StreamingProtocolControllerService();
32 0 : ClearOnShutdown(&sSingleton);
33 : }
34 0 : RefPtr<StreamingProtocolControllerService> service = sSingleton.get();
35 0 : return service.forget();
36 : }
37 :
38 : NS_IMETHODIMP
39 0 : StreamingProtocolControllerService::Create(nsIChannel *aChannel, nsIStreamingProtocolController **aResult)
40 : {
41 0 : RefPtr<nsIStreamingProtocolController> mediacontroller;
42 0 : nsCOMPtr<nsIURI> uri;
43 0 : nsAutoCString scheme;
44 :
45 0 : NS_ENSURE_ARG_POINTER(aChannel);
46 0 : aChannel->GetURI(getter_AddRefs(uri));
47 :
48 0 : nsresult rv = uri->GetScheme(scheme);
49 0 : if (NS_FAILED(rv)) return rv;
50 :
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
60 :
61 0 : if (!mediacontroller) {
62 0 : return NS_ERROR_NO_INTERFACE;
63 : }
64 :
65 0 : mediacontroller->Init(uri);
66 :
67 0 : mediacontroller.forget(aResult);
68 0 : return NS_OK;
69 : }
70 :
71 : } // namespace net
72 : } // namespace mozilla
|