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;
|
|
|
|
|
2014-04-01 06:13:50 +00:00
|
|
|
class FMRadio MOZ_FINAL : public DOMEventTargetHelper
|
2013-09-03 22:26:33 +00:00
|
|
|
, public hal::SwitchObserver
|
|
|
|
, public FMRadioEventObserver
|
|
|
|
, public nsSupportsWeakReference
|
2013-11-04 22:27:39 +00:00
|
|
|
, public nsIAudioChannelAgentCallback
|
|
|
|
, public nsIDOMEventListener
|
|
|
|
|
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 */
|
|
|
|
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 22:27:18 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
|
2013-09-03 22:26:33 +00:00
|
|
|
|
|
|
|
static bool Enabled();
|
|
|
|
|
|
|
|
bool AntennaAvailable() const;
|
|
|
|
|
|
|
|
Nullable<double> GetFrequency() const;
|
|
|
|
|
|
|
|
double FrequencyUpperBound() const;
|
|
|
|
|
|
|
|
double FrequencyLowerBound() const;
|
|
|
|
|
|
|
|
double ChannelWidth() const;
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
IMPL_EVENT_HANDLER(enabled);
|
|
|
|
IMPL_EVENT_HANDLER(disabled);
|
|
|
|
IMPL_EVENT_HANDLER(antennaavailablechange);
|
|
|
|
IMPL_EVENT_HANDLER(frequencychange);
|
|
|
|
|
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;
|
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
|
|
|
|
|