2013-09-03 22:26:33 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_FMRadio_h
|
|
|
|
#define mozilla_dom_FMRadio_h
|
|
|
|
|
2014-04-01 06:13:50 +00:00
|
|
|
#include "AudioChannelAgent.h"
|
2013-09-03 22:26:33 +00:00
|
|
|
#include "FMRadioCommon.h"
|
2014-04-01 06:13:50 +00:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2013-09-03 22:26:33 +00:00
|
|
|
#include "mozilla/HalTypes.h"
|
2014-04-01 06:13:50 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2013-09-03 22:26:33 +00:00
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
class nsIScriptContext;
|
|
|
|
|
|
|
|
BEGIN_FMRADIO_NAMESPACE
|
|
|
|
|
|
|
|
class DOMRequest;
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
class FMRadio final : public DOMEventTargetHelper
|
2015-03-27 18:52:19 +00:00
|
|
|
, public hal::SwitchObserver
|
|
|
|
, public FMRadioEventObserver
|
|
|
|
, public nsSupportsWeakReference
|
|
|
|
, public nsIAudioChannelAgentCallback
|
|
|
|
, public nsIDOMEventListener
|
2013-11-04 22:27:39 +00:00
|
|
|
|
2013-09-03 22:26:33 +00:00
|
|
|
{
|
|
|
|
friend class FMRadioRequest;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FMRadio();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-03-11 10:46:55 +00:00
|
|
|
NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
|
2013-09-03 22:26:33 +00:00
|
|
|
|
2014-04-01 06:13:50 +00:00
|
|
|
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
|
2013-09-03 22:26:33 +00:00
|
|
|
|
|
|
|
void Init(nsPIDOMWindow *aWindow);
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
/* hal::SwitchObserver */
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void Notify(const hal::SwitchEvent& aEvent) override;
|
2013-09-03 22:26:33 +00:00
|
|
|
/* FMRadioEventObserver */
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual void Notify(const FMRadioEventType& aType) override;
|
2013-09-03 22:26:33 +00:00
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-09-03 22:26:33 +00:00
|
|
|
|
|
|
|
static bool Enabled();
|
|
|
|
|
2014-09-30 16:57:52 +00:00
|
|
|
bool RdsEnabled();
|
|
|
|
|
2013-09-03 22:26:33 +00:00
|
|
|
bool AntennaAvailable() const;
|
|
|
|
|
|
|
|
Nullable<double> GetFrequency() const;
|
|
|
|
|
|
|
|
double FrequencyUpperBound() const;
|
|
|
|
|
|
|
|
double FrequencyLowerBound() const;
|
|
|
|
|
|
|
|
double ChannelWidth() const;
|
|
|
|
|
2014-09-30 16:57:52 +00:00
|
|
|
uint32_t RdsGroupMask() const;
|
|
|
|
|
|
|
|
void SetRdsGroupMask(uint32_t aRdsGroupMask);
|
|
|
|
|
|
|
|
Nullable<unsigned short> GetPi() const;
|
|
|
|
|
|
|
|
Nullable<uint8_t> GetPty() const;
|
|
|
|
|
|
|
|
void GetPs(DOMString& aPsname) const;
|
|
|
|
|
|
|
|
void GetRt(DOMString& aRadiotext) const;
|
|
|
|
|
|
|
|
void GetRdsgroup(JSContext* cx, JS::MutableHandle<JSObject*> retval);
|
|
|
|
|
2013-09-03 22:26:33 +00:00
|
|
|
already_AddRefed<DOMRequest> Enable(double aFrequency);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest> Disable();
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest> SetFrequency(double aFrequency);
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest> SeekUp();
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest> SeekDown();
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest> CancelSeek();
|
|
|
|
|
2014-09-30 16:57:52 +00:00
|
|
|
already_AddRefed<DOMRequest> EnableRDS();
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest> DisableRDS();
|
|
|
|
|
2013-09-03 22:26:33 +00:00
|
|
|
IMPL_EVENT_HANDLER(enabled);
|
|
|
|
IMPL_EVENT_HANDLER(disabled);
|
2014-09-30 16:57:52 +00:00
|
|
|
IMPL_EVENT_HANDLER(rdsenabled);
|
|
|
|
IMPL_EVENT_HANDLER(rdsdisabled);
|
2013-09-03 22:26:33 +00:00
|
|
|
IMPL_EVENT_HANDLER(antennaavailablechange);
|
|
|
|
IMPL_EVENT_HANDLER(frequencychange);
|
2014-09-30 16:57:52 +00:00
|
|
|
IMPL_EVENT_HANDLER(pichange);
|
|
|
|
IMPL_EVENT_HANDLER(ptychange);
|
|
|
|
IMPL_EVENT_HANDLER(pschange);
|
|
|
|
IMPL_EVENT_HANDLER(rtchange);
|
|
|
|
IMPL_EVENT_HANDLER(newrdsgroup);
|
2013-09-03 22:26:33 +00:00
|
|
|
|
2013-11-04 22:27:39 +00:00
|
|
|
// nsIDOMEventListener
|
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
|
|
|
|
2013-09-03 22:26:33 +00:00
|
|
|
private:
|
|
|
|
~FMRadio();
|
|
|
|
|
2013-11-04 22:27:39 +00:00
|
|
|
void SetCanPlay(bool aCanPlay);
|
2013-11-20 07:07:03 +00:00
|
|
|
void EnableAudioChannelAgent();
|
2013-11-04 22:27:39 +00:00
|
|
|
|
2013-09-03 22:26:33 +00:00
|
|
|
hal::SwitchState mHeadphoneState;
|
2014-09-30 16:57:52 +00:00
|
|
|
uint32_t mRdsGroupMask;
|
2013-11-20 07:07:03 +00:00
|
|
|
bool mAudioChannelAgentEnabled;
|
2013-09-03 22:26:33 +00:00
|
|
|
bool mHasInternalAntenna;
|
|
|
|
bool mIsShutdown;
|
2013-11-04 22:27:39 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
|
2013-09-03 22:26:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
END_FMRADIO_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_FMRadio_h
|
|
|
|
|