2014-08-21 13:15:18 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2014-08-22 08:08:34 +04:00
|
|
|
#ifndef mozilla_dom_TVTuner_h
|
|
|
|
#define mozilla_dom_TVTuner_h
|
2014-08-21 13:15:18 +04:00
|
|
|
|
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
|
|
|
// Include TVTunerBinding.h since enum TVSourceType can't be forward declared.
|
|
|
|
#include "mozilla/dom/TVTunerBinding.h"
|
|
|
|
|
2015-09-30 08:32:32 +03:00
|
|
|
#define VIDEO_TAG NS_LITERAL_STRING("video")
|
|
|
|
|
2014-08-22 08:08:34 +04:00
|
|
|
class nsITVService;
|
|
|
|
class nsITVTunerData;
|
|
|
|
|
2014-08-21 13:15:18 +04:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class DOMMediaStream;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Promise;
|
|
|
|
class TVSource;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class TVTuner final : public DOMEventTargetHelper
|
2014-08-21 13:15:18 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TVTuner, DOMEventTargetHelper)
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
static already_AddRefed<TVTuner> Create(nsPIDOMWindowInner* aWindow,
|
2014-08-22 08:08:34 +04:00
|
|
|
nsITVTunerData* aData);
|
2015-06-15 04:11:00 +03:00
|
|
|
nsresult NotifyImageSizeChanged(uint32_t aWidth, uint32_t aHeight);
|
2014-08-21 13:15:18 +04:00
|
|
|
|
|
|
|
// WebIDL (internal functions)
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2014-08-21 13:15:18 +04:00
|
|
|
|
2014-08-22 08:08:34 +04:00
|
|
|
nsresult SetCurrentSource(TVSourceType aSourceType);
|
|
|
|
|
|
|
|
nsresult DispatchTVEvent(nsIDOMEvent* aEvent);
|
|
|
|
|
2014-08-21 13:15:18 +04:00
|
|
|
// WebIDL (public APIs)
|
|
|
|
|
|
|
|
void GetSupportedSourceTypes(nsTArray<TVSourceType>& aSourceTypes,
|
|
|
|
ErrorResult& aRv) const;
|
|
|
|
|
|
|
|
already_AddRefed<Promise> GetSources(ErrorResult& aRv);
|
|
|
|
|
|
|
|
already_AddRefed<Promise> SetCurrentSource(const TVSourceType aSourceType,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
void GetId(nsAString& aId) const;
|
|
|
|
|
|
|
|
already_AddRefed<TVSource> GetCurrentSource() const;
|
|
|
|
|
|
|
|
already_AddRefed<DOMMediaStream> GetStream() const;
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(currentsourcechanged);
|
|
|
|
|
2015-09-30 08:32:32 +03:00
|
|
|
nsresult ReloadMediaStream();
|
|
|
|
|
2014-08-21 13:15:18 +04:00
|
|
|
private:
|
2016-01-30 20:05:36 +03:00
|
|
|
explicit TVTuner(nsPIDOMWindowInner* aWindow);
|
2014-08-22 08:08:34 +04:00
|
|
|
|
2014-08-21 13:15:18 +04:00
|
|
|
~TVTuner();
|
|
|
|
|
2014-08-22 08:08:34 +04:00
|
|
|
bool Init(nsITVTunerData* aData);
|
|
|
|
|
|
|
|
nsresult InitMediaStream();
|
|
|
|
|
2015-09-30 08:32:32 +03:00
|
|
|
already_AddRefed<DOMMediaStream> CreateSimulatedMediaStream();
|
|
|
|
|
2014-08-22 08:08:34 +04:00
|
|
|
nsresult DispatchCurrentSourceChangedEvent(TVSource* aSource);
|
|
|
|
|
|
|
|
nsCOMPtr<nsITVService> mTVService;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMMediaStream> mStream;
|
2015-09-30 08:32:32 +03:00
|
|
|
uint16_t mStreamType;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TVSource> mCurrentSource;
|
|
|
|
nsTArray<RefPtr<TVSource>> mSources;
|
2014-08-22 08:08:34 +04:00
|
|
|
nsString mId;
|
|
|
|
nsTArray<TVSourceType> mSupportedSourceTypes;
|
2014-08-21 13:15:18 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-08-22 08:08:34 +04:00
|
|
|
#endif // mozilla_dom_TVTuner_h
|