2012-10-24 02:30:28 +04:00
|
|
|
/*
|
2014-10-31 20:19:06 +03:00
|
|
|
* Copyright (C) 2012-2014 Mozilla Foundation
|
2012-10-24 02:30:28 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2014-02-15 02:41:07 +04:00
|
|
|
#include "GonkRecorderProfiles.h"
|
2012-10-24 02:30:28 +04:00
|
|
|
#include <media/MediaProfiles.h>
|
2014-10-31 20:19:06 +03:00
|
|
|
#include "nsMimeTypes.h"
|
2012-10-24 02:30:28 +04:00
|
|
|
#include "GonkRecorder.h"
|
|
|
|
#include "CameraControlImpl.h"
|
|
|
|
#include "CameraCommon.h"
|
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace android;
|
|
|
|
|
2014-12-03 02:14:17 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
struct ProfileConfig {
|
|
|
|
const char* name;
|
|
|
|
int quality;
|
2012-10-24 02:30:28 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define DEF_GONK_RECORDER_PROFILE(e, n) { n, e },
|
2014-12-03 02:14:17 +03:00
|
|
|
static const ProfileConfig ProfileList[] = {
|
|
|
|
#include "GonkRecorderProfiles.def"
|
|
|
|
};
|
|
|
|
|
|
|
|
static const size_t ProfileListSize = MOZ_ARRAY_LENGTH(ProfileList);
|
|
|
|
|
|
|
|
struct ProfileConfigDetect {
|
2012-10-24 02:30:28 +04:00
|
|
|
const char* name;
|
2014-12-03 02:14:17 +03:00
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DEF_GONK_RECORDER_PROFILE_DETECT(n, w, h) { n, w, h },
|
|
|
|
static const ProfileConfigDetect ProfileListDetect[] = {
|
2012-10-24 02:30:28 +04:00
|
|
|
#include "GonkRecorderProfiles.def"
|
2014-12-03 02:14:17 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static const size_t ProfileListDetectSize = MOZ_ARRAY_LENGTH(ProfileListDetect);
|
|
|
|
|
2012-10-24 02:30:28 +04:00
|
|
|
};
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
/* static */ nsClassHashtable<nsUint32HashKey, ProfileHashtable> GonkRecorderProfile::sProfiles;
|
|
|
|
/* static */ android::MediaProfiles* sMediaProfiles = nullptr;
|
2012-10-24 02:30:28 +04:00
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
static MediaProfiles*
|
|
|
|
GetMediaProfiles()
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
|
|
|
if (!sMediaProfiles) {
|
|
|
|
sMediaProfiles = MediaProfiles::getInstance();
|
|
|
|
}
|
2014-10-31 20:19:06 +03:00
|
|
|
MOZ_ASSERT(sMediaProfiles);
|
|
|
|
return sMediaProfiles;
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
static bool
|
2014-12-03 02:14:17 +03:00
|
|
|
IsProfileSupported(uint32_t aCameraId, int aQuality)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
MediaProfiles* profiles = GetMediaProfiles();
|
2014-12-03 02:14:17 +03:00
|
|
|
return profiles->hasCamcorderProfile(static_cast<int>(aCameraId),
|
|
|
|
static_cast<camcorder_quality>(aQuality));
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
static int
|
2014-12-03 02:14:17 +03:00
|
|
|
GetProfileParameter(uint32_t aCameraId, int aQuality, const char* aParameter)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
MediaProfiles* profiles = GetMediaProfiles();
|
2014-12-03 02:14:17 +03:00
|
|
|
return profiles->getCamcorderProfileParamByName(aParameter, static_cast<int>(aCameraId),
|
|
|
|
static_cast<camcorder_quality>(aQuality));
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
/* static */ bool
|
|
|
|
GonkRecorderVideo::Translate(video_encoder aCodec, nsAString& aCodecName)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
switch (aCodec) {
|
|
|
|
case VIDEO_ENCODER_H263:
|
|
|
|
aCodecName.AssignASCII("h263");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIDEO_ENCODER_H264:
|
|
|
|
aCodecName.AssignASCII("h264");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VIDEO_ENCODER_MPEG_4_SP:
|
|
|
|
aCodecName.AssignASCII("mpeg4sp");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
2014-10-31 20:19:06 +03:00
|
|
|
|
|
|
|
return true;
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
int
|
|
|
|
GonkRecorderVideo::GetProfileParameter(const char* aParameter)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-12-03 02:14:17 +03:00
|
|
|
return ::GetProfileParameter(mCameraId, mQuality, aParameter);
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-12-03 02:14:17 +03:00
|
|
|
GonkRecorderVideo::GonkRecorderVideo(uint32_t aCameraId, int aQuality)
|
2014-10-31 20:19:06 +03:00
|
|
|
: mCameraId(aCameraId)
|
2014-12-03 02:14:17 +03:00
|
|
|
, mQuality(aQuality)
|
2014-10-31 20:19:06 +03:00
|
|
|
, mIsValid(false)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
mPlatformEncoder = static_cast<video_encoder>(GetProfileParameter("vid.codec"));
|
|
|
|
bool isValid = Translate(mPlatformEncoder, mCodec);
|
|
|
|
|
|
|
|
int v = GetProfileParameter("vid.width");
|
|
|
|
if (v >= 0) {
|
|
|
|
mSize.width = v;
|
|
|
|
} else {
|
|
|
|
isValid = false;
|
|
|
|
}
|
|
|
|
v = GetProfileParameter("vid.height");
|
|
|
|
if (v >= 0) {
|
|
|
|
mSize.height = v;
|
|
|
|
} else {
|
|
|
|
isValid = false;
|
|
|
|
}
|
|
|
|
v = GetProfileParameter("vid.bps");
|
|
|
|
if (v >= 0) {
|
|
|
|
mBitsPerSecond = v;
|
|
|
|
} else {
|
|
|
|
isValid = false;
|
|
|
|
}
|
|
|
|
v = GetProfileParameter("vid.fps");
|
|
|
|
if (v >= 0) {
|
|
|
|
mFramesPerSecond = v;
|
|
|
|
} else {
|
|
|
|
isValid = false;
|
2014-04-26 00:28:15 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
mIsValid = isValid;
|
|
|
|
}
|
2012-10-24 02:30:28 +04:00
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
/* static */ bool
|
|
|
|
GonkRecorderAudio::Translate(audio_encoder aCodec, nsAString& aCodecName)
|
|
|
|
{
|
|
|
|
switch (aCodec) {
|
|
|
|
case AUDIO_ENCODER_AMR_NB:
|
|
|
|
aCodecName.AssignASCII("amrnb");
|
|
|
|
break;
|
2012-10-24 02:30:28 +04:00
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
case AUDIO_ENCODER_AMR_WB:
|
|
|
|
aCodecName.AssignASCII("amrwb");
|
|
|
|
break;
|
2012-10-24 02:30:28 +04:00
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
case AUDIO_ENCODER_AAC:
|
|
|
|
aCodecName.AssignASCII("aac");
|
|
|
|
break;
|
2012-10-24 02:30:28 +04:00
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2012-10-24 02:30:28 +04:00
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
return true;
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
int
|
|
|
|
GonkRecorderAudio::GetProfileParameter(const char* aParameter)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-12-03 02:14:17 +03:00
|
|
|
return ::GetProfileParameter(mCameraId, mQuality, aParameter);
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-12-03 02:14:17 +03:00
|
|
|
GonkRecorderAudio::GonkRecorderAudio(uint32_t aCameraId, int aQuality)
|
2014-10-31 20:19:06 +03:00
|
|
|
: mCameraId(aCameraId)
|
2014-12-03 02:14:17 +03:00
|
|
|
, mQuality(aQuality)
|
2014-10-31 20:19:06 +03:00
|
|
|
, mIsValid(false)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
mPlatformEncoder = static_cast<audio_encoder>(GetProfileParameter("aud.codec"));
|
|
|
|
bool isValid = Translate(mPlatformEncoder, mCodec);
|
|
|
|
|
|
|
|
int v = GetProfileParameter("aud.ch");
|
|
|
|
if (v >= 0) {
|
|
|
|
mChannels = v;
|
|
|
|
} else {
|
|
|
|
isValid = false;
|
|
|
|
}
|
|
|
|
v = GetProfileParameter("aud.bps");
|
|
|
|
if (v >= 0) {
|
|
|
|
mBitsPerSecond = v;
|
|
|
|
} else {
|
|
|
|
isValid = false;
|
|
|
|
}
|
|
|
|
v = GetProfileParameter("aud.hz");
|
|
|
|
if (v >= 0) {
|
|
|
|
mSamplesPerSecond = v;
|
|
|
|
} else {
|
|
|
|
isValid = false;
|
|
|
|
}
|
2012-10-24 02:30:28 +04:00
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
mIsValid = isValid;
|
2014-11-01 01:51:23 +03:00
|
|
|
}
|
2014-10-31 20:19:06 +03:00
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
/* static */ bool
|
|
|
|
GonkRecorderProfile::Translate(output_format aContainer, nsAString& aContainerName)
|
2014-11-01 01:51:23 +03:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
switch (aContainer) {
|
|
|
|
case OUTPUT_FORMAT_THREE_GPP:
|
|
|
|
aContainerName.AssignASCII("3gp");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OUTPUT_FORMAT_MPEG_4:
|
|
|
|
aContainerName.AssignASCII("mp4");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
2014-10-31 20:19:06 +03:00
|
|
|
}
|
2014-10-31 20:19:06 +03:00
|
|
|
|
|
|
|
return true;
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
/* static */ bool
|
|
|
|
GonkRecorderProfile::GetMimeType(output_format aContainer, nsAString& aMimeType)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
switch (aContainer) {
|
|
|
|
case OUTPUT_FORMAT_THREE_GPP:
|
|
|
|
aMimeType.AssignASCII(VIDEO_3GPP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OUTPUT_FORMAT_MPEG_4:
|
|
|
|
aMimeType.AssignASCII(VIDEO_MP4);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
int
|
|
|
|
GonkRecorderProfile::GetProfileParameter(const char* aParameter)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-12-03 02:14:17 +03:00
|
|
|
return ::GetProfileParameter(mCameraId, mQuality, aParameter);
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
GonkRecorderProfile::GonkRecorderProfile(uint32_t aCameraId,
|
2014-12-03 02:14:17 +03:00
|
|
|
int aQuality)
|
2014-10-31 20:19:06 +03:00
|
|
|
: GonkRecorderProfileBase<GonkRecorderAudio, GonkRecorderVideo>(aCameraId,
|
2014-12-03 02:14:17 +03:00
|
|
|
aQuality)
|
2014-10-31 20:19:06 +03:00
|
|
|
, mCameraId(aCameraId)
|
2014-12-03 02:14:17 +03:00
|
|
|
, mQuality(aQuality)
|
2014-10-31 20:19:06 +03:00
|
|
|
, mIsValid(false)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
mOutputFormat = static_cast<output_format>(GetProfileParameter("file.format"));
|
|
|
|
bool isValid = Translate(mOutputFormat, mContainer);
|
|
|
|
isValid = GetMimeType(mOutputFormat, mMimeType) ? isValid : false;
|
|
|
|
|
|
|
|
mIsValid = isValid && mAudio.IsValid() && mVideo.IsValid();
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
/* static */ PLDHashOperator
|
|
|
|
GonkRecorderProfile::Enumerate(const nsAString& aProfileName,
|
|
|
|
GonkRecorderProfile* aProfile,
|
|
|
|
void* aUserArg)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
nsTArray<nsRefPtr<ICameraControl::RecorderProfile>>* profiles =
|
|
|
|
static_cast<nsTArray<nsRefPtr<ICameraControl::RecorderProfile>>*>(aUserArg);
|
|
|
|
MOZ_ASSERT(profiles);
|
|
|
|
profiles->AppendElement(aProfile);
|
|
|
|
return PL_DHASH_NEXT;
|
2014-10-31 20:19:06 +03:00
|
|
|
}
|
2012-10-24 02:30:28 +04:00
|
|
|
|
2014-12-03 02:14:17 +03:00
|
|
|
/* static */
|
|
|
|
already_AddRefed<GonkRecorderProfile>
|
|
|
|
GonkRecorderProfile::CreateProfile(uint32_t aCameraId, int aQuality)
|
|
|
|
{
|
|
|
|
if (!IsProfileSupported(aCameraId, aQuality)) {
|
|
|
|
DOM_CAMERA_LOGI("Profile %d not supported by platform\n", aQuality);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<GonkRecorderProfile> profile = new GonkRecorderProfile(aCameraId, aQuality);
|
|
|
|
if (!profile->IsValid()) {
|
|
|
|
DOM_CAMERA_LOGE("Profile %d is not valid\n", aQuality);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return profile.forget();
|
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
/* static */
|
|
|
|
ProfileHashtable*
|
|
|
|
GonkRecorderProfile::GetProfileHashtable(uint32_t aCameraId)
|
2014-10-31 20:19:06 +03:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
ProfileHashtable* profiles = sProfiles.Get(aCameraId);
|
|
|
|
if (!profiles) {
|
2014-12-03 02:14:17 +03:00
|
|
|
profiles = new ProfileHashtable();
|
2014-10-31 20:19:06 +03:00
|
|
|
sProfiles.Put(aCameraId, profiles);
|
|
|
|
|
2014-12-03 02:14:17 +03:00
|
|
|
/* First handle the profiles with a known enum. We can process those
|
|
|
|
efficently because MediaProfiles indexes their profiles that way. */
|
|
|
|
int highestKnownQuality = CAMCORDER_QUALITY_LIST_START - 1;
|
|
|
|
for (size_t i = 0; i < ProfileListSize; ++i) {
|
|
|
|
const ProfileConfig& p = ProfileList[i];
|
|
|
|
if (p.quality > highestKnownQuality) {
|
|
|
|
highestKnownQuality = p.quality;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<GonkRecorderProfile> profile = CreateProfile(aCameraId, p.quality);
|
|
|
|
if (!profile) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
DOM_CAMERA_LOGI("Profile %d '%s' supported by platform\n", p.quality, p.name);
|
|
|
|
profile->mName.AssignASCII(p.name);
|
|
|
|
profiles->Put(profile->GetName(), profile);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* However not all of the potentially supported profiles have a known
|
|
|
|
enum on all of our supported platforms because some entries may
|
|
|
|
be missing from MediaProfiles.h. As such, we can't rely upon
|
|
|
|
having the CAMCORDER_QUALITY_* enums for those profiles. We need
|
|
|
|
to map the profiles to a name by matching the width and height of
|
|
|
|
the video resolution to our configured values.
|
|
|
|
|
|
|
|
In theory there may be collisions given that there can be multiple
|
|
|
|
resolutions sharing the same name (e.g. 800x480 and 768x480 are both
|
|
|
|
wvga). In practice this should not happen because there should be
|
|
|
|
only one WVGA profile given there is only one enum for it. In the
|
|
|
|
situation there is a collision, it will merely select the last
|
|
|
|
detected profile. */
|
|
|
|
for (int q = highestKnownQuality + 1; q <= CAMCORDER_QUALITY_LIST_END; ++q) {
|
|
|
|
nsRefPtr<GonkRecorderProfile> profile = CreateProfile(aCameraId, q);
|
|
|
|
if (!profile) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ICameraControl::Size& s = profile->GetVideo().GetSize();
|
|
|
|
size_t match;
|
|
|
|
for (match = 0; match < ProfileListDetectSize; ++match) {
|
|
|
|
const ProfileConfigDetect& p = ProfileListDetect[match];
|
|
|
|
if (s.width == p.width && s.height == p.height) {
|
|
|
|
DOM_CAMERA_LOGI("Profile %d '%s' supported by platform\n", q, p.name);
|
|
|
|
profile->mName.AssignASCII(p.name);
|
|
|
|
profiles->Put(profile->GetName(), profile);
|
|
|
|
break;
|
2014-10-31 20:19:06 +03:00
|
|
|
}
|
2014-12-03 02:14:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (match == ProfileListDetectSize) {
|
|
|
|
DOM_CAMERA_LOGW("Profile %d size %u x %u is not recognized\n",
|
|
|
|
q, s.width, s.height);
|
2014-10-31 20:19:06 +03:00
|
|
|
}
|
|
|
|
}
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
2014-10-31 20:19:06 +03:00
|
|
|
return profiles;
|
|
|
|
}
|
2012-10-24 02:30:28 +04:00
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
/* static */ nsresult
|
|
|
|
GonkRecorderProfile::GetAll(uint32_t aCameraId,
|
|
|
|
nsTArray<nsRefPtr<ICameraControl::RecorderProfile>>& aProfiles)
|
|
|
|
{
|
|
|
|
ProfileHashtable* profiles = GetProfileHashtable(aCameraId);
|
|
|
|
if (!profiles) {
|
|
|
|
return NS_ERROR_FAILURE;
|
2014-11-01 01:51:23 +03:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
aProfiles.Clear();
|
|
|
|
profiles->EnumerateRead(Enumerate, static_cast<void*>(&aProfiles));
|
|
|
|
|
|
|
|
return NS_OK;
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
nsresult
|
|
|
|
GonkRecorderProfile::ConfigureRecorder(GonkRecorder& aRecorder)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
static const size_t SIZE = 256;
|
|
|
|
char buffer[SIZE];
|
|
|
|
|
|
|
|
// set all the params
|
|
|
|
CHECK_SETARG(aRecorder.setAudioSource(AUDIO_SOURCE_CAMCORDER));
|
|
|
|
CHECK_SETARG(aRecorder.setVideoSource(VIDEO_SOURCE_CAMERA));
|
|
|
|
CHECK_SETARG(aRecorder.setOutputFormat(mOutputFormat));
|
|
|
|
CHECK_SETARG(aRecorder.setVideoFrameRate(mVideo.GetFramesPerSecond()));
|
|
|
|
CHECK_SETARG(aRecorder.setVideoSize(mVideo.GetSize().width, mVideo.GetSize().height));
|
|
|
|
CHECK_SETARG(aRecorder.setVideoEncoder(mVideo.GetPlatformEncoder()));
|
|
|
|
CHECK_SETARG(aRecorder.setAudioEncoder(mAudio.GetPlatformEncoder()));
|
|
|
|
|
|
|
|
snprintf(buffer, SIZE, "video-param-encoding-bitrate=%d", mVideo.GetBitsPerSecond());
|
|
|
|
CHECK_SETARG(aRecorder.setParameters(String8(buffer)));
|
|
|
|
|
|
|
|
snprintf(buffer, SIZE, "audio-param-encoding-bitrate=%d", mAudio.GetBitsPerSecond());
|
|
|
|
CHECK_SETARG(aRecorder.setParameters(String8(buffer)));
|
|
|
|
|
|
|
|
snprintf(buffer, SIZE, "audio-param-number-of-channels=%d", mAudio.GetChannels());
|
|
|
|
CHECK_SETARG(aRecorder.setParameters(String8(buffer)));
|
|
|
|
|
|
|
|
snprintf(buffer, SIZE, "audio-param-sampling-rate=%d", mAudio.GetSamplesPerSecond());
|
|
|
|
CHECK_SETARG(aRecorder.setParameters(String8(buffer)));
|
|
|
|
|
|
|
|
return NS_OK;
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
/* static */ nsresult
|
|
|
|
GonkRecorderProfile::ConfigureRecorder(android::GonkRecorder& aRecorder,
|
|
|
|
uint32_t aCameraId,
|
|
|
|
const nsAString& aProfileName)
|
2012-10-24 02:30:28 +04:00
|
|
|
{
|
2014-10-31 20:19:06 +03:00
|
|
|
ProfileHashtable* profiles = GetProfileHashtable(aCameraId);
|
|
|
|
if (!profiles) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GonkRecorderProfile* profile;
|
|
|
|
if (!profiles->Get(aProfileName, &profile)) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|
|
|
|
|
2014-10-31 20:19:06 +03:00
|
|
|
return profile->ConfigureRecorder(aRecorder);
|
2012-10-24 02:30:28 +04:00
|
|
|
}
|