2013-09-03 15:26:33 -07: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-03-31 23:13:50 -07:00
|
|
|
#include "AudioChannelAgent.h"
|
2013-09-03 15:26:33 -07:00
|
|
|
#include "FMRadioCommon.h"
|
2014-03-31 23:13:50 -07:00
|
|
|
#include "mozilla/DOMEventTargetHelper.h"
|
2013-09-03 15:26:33 -07:00
|
|
|
#include "mozilla/HalTypes.h"
|
2014-03-31 23:13:50 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2013-09-03 15:26:33 -07:00
|
|
|
#include "nsWeakReference.h"
|
|
|
|
|
|
|
|
class nsPIDOMWindow;
|
|
|
|
class nsIScriptContext;
|
|
|
|
|
|
|
|
BEGIN_FMRADIO_NAMESPACE
|
|
|
|
|
|
|
|
class DOMRequest;
|
|
|
|
|
2014-03-31 23:13:50 -07:00
|
|
|
class FMRadio MOZ_FINAL : public DOMEventTargetHelper
|
2013-09-03 15:26:33 -07:00
|
|
|
, public hal::SwitchObserver
|
|
|
|
, public FMRadioEventObserver
|
|
|
|
, public nsSupportsWeakReference
|
2013-11-04 14:27:39 -08:00
|
|
|
, public nsIAudioChannelAgentCallback
|
|
|
|
, public nsIDOMEventListener
|
|
|
|
|
2013-09-03 15:26:33 -07:00
|
|
|
{
|
|
|
|
friend class FMRadioRequest;
|
|
|
|
|
|
|
|
public:
|
|
|
|
FMRadio();
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2014-03-11 03:46:55 -07:00
|
|
|
NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
|
2013-09-03 15:26:33 -07:00
|
|
|
|
2014-03-31 23:13:50 -07:00
|
|
|
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
|
2013-09-03 15:26:33 -07:00
|
|
|
|
|
|
|
void Init(nsPIDOMWindow *aWindow);
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
/* hal::SwitchObserver */
|
|
|
|
virtual void Notify(const hal::SwitchEvent& aEvent) MOZ_OVERRIDE;
|
|
|
|
/* FMRadioEventObserver */
|
|
|
|
virtual void Notify(const FMRadioEventType& aType) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
nsPIDOMWindow* GetParentObject() const
|
|
|
|
{
|
|
|
|
return GetOwner();
|
|
|
|
}
|
|
|
|
|
2014-04-08 15:27:18 -07:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-09-03 15:26:33 -07:00
|
|
|
|
|
|
|
static bool Enabled();
|
|
|
|
|
2014-09-30 09:57:52 -07:00
|
|
|
bool RdsEnabled();
|
|
|
|
|
2013-09-03 15:26:33 -07:00
|
|
|
bool AntennaAvailable() const;
|
|
|
|
|
|
|
|
Nullable<double> GetFrequency() const;
|
|
|
|
|
|
|
|
double FrequencyUpperBound() const;
|
|
|
|
|
|
|
|
double FrequencyLowerBound() const;
|
|
|
|
|
|
|
|
double ChannelWidth() const;
|
|
|
|
|
2014-09-30 09:57:52 -07: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 15:26:33 -07: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 09:57:52 -07:00
|
|
|
already_AddRefed<DOMRequest> EnableRDS();
|
|
|
|
|
|
|
|
already_AddRefed<DOMRequest> DisableRDS();
|
|
|
|
|
2013-09-03 15:26:33 -07:00
|
|
|
IMPL_EVENT_HANDLER(enabled);
|
|
|
|
IMPL_EVENT_HANDLER(disabled);
|
2014-09-30 09:57:52 -07:00
|
|
|
IMPL_EVENT_HANDLER(rdsenabled);
|
|
|
|
IMPL_EVENT_HANDLER(rdsdisabled);
|
2013-09-03 15:26:33 -07:00
|
|
|
IMPL_EVENT_HANDLER(antennaavailablechange);
|
|
|
|
IMPL_EVENT_HANDLER(frequencychange);
|
2014-09-30 09:57:52 -07:00
|
|
|
IMPL_EVENT_HANDLER(pichange);
|
|
|
|
IMPL_EVENT_HANDLER(ptychange);
|
|
|
|
IMPL_EVENT_HANDLER(pschange);
|
|
|
|
IMPL_EVENT_HANDLER(rtchange);
|
|
|
|
IMPL_EVENT_HANDLER(newrdsgroup);
|
2013-09-03 15:26:33 -07:00
|
|
|
|
2013-11-04 14:27:39 -08:00
|
|
|
// nsIDOMEventListener
|
|
|
|
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
|
|
|
|
|
2013-09-03 15:26:33 -07:00
|
|
|
private:
|
|
|
|
~FMRadio();
|
|
|
|
|
2013-11-04 14:27:39 -08:00
|
|
|
void SetCanPlay(bool aCanPlay);
|
2013-11-19 23:07:03 -08:00
|
|
|
void EnableAudioChannelAgent();
|
2013-11-04 14:27:39 -08:00
|
|
|
|
2013-09-03 15:26:33 -07:00
|
|
|
hal::SwitchState mHeadphoneState;
|
2014-09-30 09:57:52 -07:00
|
|
|
uint32_t mRdsGroupMask;
|
2013-11-19 23:07:03 -08:00
|
|
|
bool mAudioChannelAgentEnabled;
|
2013-09-03 15:26:33 -07:00
|
|
|
bool mHasInternalAntenna;
|
|
|
|
bool mIsShutdown;
|
2013-11-04 14:27:39 -08:00
|
|
|
|
|
|
|
nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
|
2013-09-03 15:26:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
END_FMRADIO_NAMESPACE
|
|
|
|
|
|
|
|
#endif // mozilla_dom_FMRadio_h
|
|
|
|
|