1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_TVTuner_h
8 #define mozilla_dom_TVTuner_h
10 #include "mozilla/DOMEventTargetHelper.h"
11 // Include TVTunerBinding.h since enum TVSourceType can't be forward declared.
12 #include "mozilla/dom/TVTunerBinding.h"
26 class TVTuner MOZ_FINAL
: public DOMEventTargetHelper
29 NS_DECL_ISUPPORTS_INHERITED
30 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TVTuner
, DOMEventTargetHelper
)
32 static already_AddRefed
<TVTuner
> Create(nsPIDOMWindow
* aWindow
,
33 nsITVTunerData
* aData
);
35 // WebIDL (internal functions)
37 virtual JSObject
* WrapObject(JSContext
*aCx
) MOZ_OVERRIDE
;
39 nsresult
SetCurrentSource(TVSourceType aSourceType
);
41 nsresult
DispatchTVEvent(nsIDOMEvent
* aEvent
);
43 // WebIDL (public APIs)
45 void GetSupportedSourceTypes(nsTArray
<TVSourceType
>& aSourceTypes
,
46 ErrorResult
& aRv
) const;
48 already_AddRefed
<Promise
> GetSources(ErrorResult
& aRv
);
50 already_AddRefed
<Promise
> SetCurrentSource(const TVSourceType aSourceType
,
53 void GetId(nsAString
& aId
) const;
55 already_AddRefed
<TVSource
> GetCurrentSource() const;
57 already_AddRefed
<DOMMediaStream
> GetStream() const;
59 IMPL_EVENT_HANDLER(currentsourcechanged
);
62 explicit TVTuner(nsPIDOMWindow
* aWindow
);
66 bool Init(nsITVTunerData
* aData
);
68 nsresult
InitMediaStream();
70 nsresult
DispatchCurrentSourceChangedEvent(TVSource
* aSource
);
72 nsCOMPtr
<nsITVService
> mTVService
;
73 nsRefPtr
<DOMMediaStream
> mStream
;
74 nsRefPtr
<TVSource
> mCurrentSource
;
75 nsTArray
<nsRefPtr
<TVSource
>> mSources
;
77 nsTArray
<TVSourceType
> mSupportedSourceTypes
;
81 } // namespace mozilla
83 #endif // mozilla_dom_TVTuner_h