dom/camera/GonkRecorderProfiles.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/camera/GonkRecorderProfiles.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,113 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef DOM_CAMERA_GONK_RECORDER_PROFILES_H
     1.9 +#define DOM_CAMERA_GONK_RECORDER_PROFILES_H
    1.10 +
    1.11 +#include <media/MediaProfiles.h>
    1.12 +#include "CameraRecorderProfiles.h"
    1.13 +#include "ICameraControl.h"
    1.14 +
    1.15 +#ifndef CHECK_SETARG
    1.16 +#define CHECK_SETARG(x)                 \
    1.17 +  do {                                  \
    1.18 +    if (x) {                            \
    1.19 +      DOM_CAMERA_LOGE(#x " failed\n");  \
    1.20 +      return NS_ERROR_INVALID_ARG;      \
    1.21 +    }                                   \
    1.22 +  } while(0)
    1.23 +#endif
    1.24 +
    1.25 +
    1.26 +namespace android {
    1.27 +class GonkRecorder;
    1.28 +};
    1.29 +
    1.30 +namespace mozilla {
    1.31 +
    1.32 +/**
    1.33 + * Gonk-specific video profile.
    1.34 + */
    1.35 +class GonkRecorderVideoProfile : public RecorderVideoProfile
    1.36 +{
    1.37 +public:
    1.38 +  GonkRecorderVideoProfile(uint32_t aCameraId, uint32_t aQualityIndex);
    1.39 +  ~GonkRecorderVideoProfile();
    1.40 +  android::video_encoder GetPlatformCodec() const { return mPlatformCodec; }
    1.41 +
    1.42 +protected:
    1.43 +  android::video_encoder mPlatformCodec;
    1.44 +};
    1.45 +
    1.46 +/**
    1.47 + * Gonk-specific audio profile.
    1.48 + */
    1.49 +class GonkRecorderAudioProfile : public RecorderAudioProfile
    1.50 +{
    1.51 +public:
    1.52 +  GonkRecorderAudioProfile(uint32_t aCameraId, uint32_t aQualityIndex);
    1.53 +  ~GonkRecorderAudioProfile();
    1.54 +  android::audio_encoder GetPlatformCodec() const { return mPlatformCodec; }
    1.55 +
    1.56 +protected:
    1.57 +  android::audio_encoder mPlatformCodec;
    1.58 +};
    1.59 +
    1.60 +/**
    1.61 + * Gonk-specific recorder profile.
    1.62 + */
    1.63 +class GonkRecorderProfile : public RecorderProfileBase<GonkRecorderAudioProfile, GonkRecorderVideoProfile>
    1.64 +{
    1.65 +public:
    1.66 +  GonkRecorderProfile(uint32_t aCameraId, uint32_t aQualityIndex);
    1.67 +
    1.68 +  GonkRecorderAudioProfile* GetGonkAudioProfile() { return &mAudio; }
    1.69 +  GonkRecorderVideoProfile* GetGonkVideoProfile() { return &mVideo; }
    1.70 +
    1.71 +  android::output_format GetOutputFormat() const { return mPlatformOutputFormat; }
    1.72 +  nsresult ConfigureRecorder(android::GonkRecorder* aRecorder);
    1.73 +
    1.74 +protected:
    1.75 +  virtual ~GonkRecorderProfile();
    1.76 +
    1.77 +  android::output_format mPlatformOutputFormat;
    1.78 +};
    1.79 +
    1.80 +/**
    1.81 + * Gonk-specific profile manager.
    1.82 + */
    1.83 +class GonkRecorderProfileManager : public RecorderProfileManager
    1.84 +{
    1.85 +public:
    1.86 +  GonkRecorderProfileManager(uint32_t aCameraId);
    1.87 +
    1.88 +  /**
    1.89 +   * Call this function to indicate that the specified resolutions are in fact
    1.90 +   * supported by the camera hardware.  (Just because it appears in a recorder
    1.91 +   * profile doesn't mean the hardware can handle it.)
    1.92 +   */
    1.93 +  void SetSupportedResolutions(const nsTArray<ICameraControl::Size>& aSizes)
    1.94 +    { mSupportedSizes = aSizes; }
    1.95 +
    1.96 +  /**
    1.97 +   * Call this function to remove all resolutions set by calling
    1.98 +   * SetSupportedResolutions().
    1.99 +   */
   1.100 +  void ClearSupportedResolutions() { mSupportedSizes.Clear(); }
   1.101 +
   1.102 +  bool IsSupported(uint32_t aQualityIndex) const;
   1.103 +
   1.104 +  already_AddRefed<RecorderProfile> Get(uint32_t aQualityIndex) const;
   1.105 +  already_AddRefed<GonkRecorderProfile> Get(const char* aProfileName) const;
   1.106 +  nsresult ConfigureRecorder(android::GonkRecorder* aRecorder);
   1.107 +
   1.108 +protected:
   1.109 +  virtual ~GonkRecorderProfileManager();
   1.110 +
   1.111 +  nsTArray<ICameraControl::Size> mSupportedSizes;
   1.112 +};
   1.113 +
   1.114 +}; // namespace mozilla
   1.115 +
   1.116 +#endif // DOM_CAMERA_GONK_RECORDER_PROFILES_H

mercurial