dom/fmradio/FMRadio.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/fmradio/FMRadio.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,105 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef mozilla_dom_FMRadio_h
    1.10 +#define mozilla_dom_FMRadio_h
    1.11 +
    1.12 +#include "AudioChannelAgent.h"
    1.13 +#include "FMRadioCommon.h"
    1.14 +#include "mozilla/DOMEventTargetHelper.h"
    1.15 +#include "mozilla/HalTypes.h"
    1.16 +#include "nsCycleCollectionParticipant.h"
    1.17 +#include "nsWeakReference.h"
    1.18 +
    1.19 +class nsPIDOMWindow;
    1.20 +class nsIScriptContext;
    1.21 +
    1.22 +BEGIN_FMRADIO_NAMESPACE
    1.23 +
    1.24 +class DOMRequest;
    1.25 +
    1.26 +class FMRadio MOZ_FINAL : public DOMEventTargetHelper
    1.27 +                        , public hal::SwitchObserver
    1.28 +                        , public FMRadioEventObserver
    1.29 +                        , public nsSupportsWeakReference
    1.30 +                        , public nsIAudioChannelAgentCallback
    1.31 +                        , public nsIDOMEventListener
    1.32 +
    1.33 +{
    1.34 +  friend class FMRadioRequest;
    1.35 +
    1.36 +public:
    1.37 +  FMRadio();
    1.38 +
    1.39 +  NS_DECL_ISUPPORTS_INHERITED
    1.40 +  NS_DECL_NSIAUDIOCHANNELAGENTCALLBACK
    1.41 +
    1.42 +  NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
    1.43 +
    1.44 +  void Init(nsPIDOMWindow *aWindow);
    1.45 +  void Shutdown();
    1.46 +
    1.47 +  /* hal::SwitchObserver */
    1.48 +  virtual void Notify(const hal::SwitchEvent& aEvent) MOZ_OVERRIDE;
    1.49 +  /* FMRadioEventObserver */
    1.50 +  virtual void Notify(const FMRadioEventType& aType) MOZ_OVERRIDE;
    1.51 +
    1.52 +  nsPIDOMWindow* GetParentObject() const
    1.53 +  {
    1.54 +    return GetOwner();
    1.55 +  }
    1.56 +
    1.57 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.58 +
    1.59 +  static bool Enabled();
    1.60 +
    1.61 +  bool AntennaAvailable() const;
    1.62 +
    1.63 +  Nullable<double> GetFrequency() const;
    1.64 +
    1.65 +  double FrequencyUpperBound() const;
    1.66 +
    1.67 +  double FrequencyLowerBound() const;
    1.68 +
    1.69 +  double ChannelWidth() const;
    1.70 +
    1.71 +  already_AddRefed<DOMRequest> Enable(double aFrequency);
    1.72 +
    1.73 +  already_AddRefed<DOMRequest> Disable();
    1.74 +
    1.75 +  already_AddRefed<DOMRequest> SetFrequency(double aFrequency);
    1.76 +
    1.77 +  already_AddRefed<DOMRequest> SeekUp();
    1.78 +
    1.79 +  already_AddRefed<DOMRequest> SeekDown();
    1.80 +
    1.81 +  already_AddRefed<DOMRequest> CancelSeek();
    1.82 +
    1.83 +  IMPL_EVENT_HANDLER(enabled);
    1.84 +  IMPL_EVENT_HANDLER(disabled);
    1.85 +  IMPL_EVENT_HANDLER(antennaavailablechange);
    1.86 +  IMPL_EVENT_HANDLER(frequencychange);
    1.87 +
    1.88 +  // nsIDOMEventListener
    1.89 +  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
    1.90 +
    1.91 +private:
    1.92 +  ~FMRadio();
    1.93 +
    1.94 +  void SetCanPlay(bool aCanPlay);
    1.95 +  void EnableAudioChannelAgent();
    1.96 +
    1.97 +  hal::SwitchState mHeadphoneState;
    1.98 +  bool mAudioChannelAgentEnabled;
    1.99 +  bool mHasInternalAntenna;
   1.100 +  bool mIsShutdown;
   1.101 +
   1.102 +  nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent;
   1.103 +};
   1.104 +
   1.105 +END_FMRADIO_NAMESPACE
   1.106 +
   1.107 +#endif // mozilla_dom_FMRadio_h
   1.108 +

mercurial