Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | diff --git a/dom/camera/GonkCameraSource.cpp b/dom/camera/GonkCameraSource.cpp |
michael@0 | 2 | --- a/dom/camera/GonkCameraSource.cpp |
michael@0 | 3 | +++ b/dom/camera/GonkCameraSource.cpp |
michael@0 | 4 | @@ -492,21 +492,17 @@ status_t GonkCameraSource::init( |
michael@0 | 5 | mMeta = new MetaData; |
michael@0 | 6 | mMeta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_RAW); |
michael@0 | 7 | mMeta->setInt32(kKeyColorFormat, mColorFormat); |
michael@0 | 8 | mMeta->setInt32(kKeyWidth, mVideoSize.width); |
michael@0 | 9 | mMeta->setInt32(kKeyHeight, mVideoSize.height); |
michael@0 | 10 | mMeta->setInt32(kKeyStride, mVideoSize.width); |
michael@0 | 11 | mMeta->setInt32(kKeySliceHeight, mVideoSize.height); |
michael@0 | 12 | mMeta->setInt32(kKeyFrameRate, mVideoFrameRate); |
michael@0 | 13 | - mMeta->setInt32(kKeyHFR, hfr); |
michael@0 | 14 | |
michael@0 | 15 | - if (want3D) { |
michael@0 | 16 | - mMeta->setInt32(kKey3D, !0); |
michael@0 | 17 | - } |
michael@0 | 18 | return OK; |
michael@0 | 19 | } |
michael@0 | 20 | |
michael@0 | 21 | GonkCameraSource::~GonkCameraSource() { |
michael@0 | 22 | if (mStarted) { |
michael@0 | 23 | stop(); |
michael@0 | 24 | } else if (mInitCheck == OK) { |
michael@0 | 25 | // Camera is initialized but because start() is never called, |
michael@0 | 26 | diff --git a/dom/camera/GonkRecorder.cpp b/dom/camera/GonkRecorder.cpp |
michael@0 | 27 | --- a/dom/camera/GonkRecorder.cpp |
michael@0 | 28 | +++ b/dom/camera/GonkRecorder.cpp |
michael@0 | 29 | @@ -716,56 +716,16 @@ status_t GonkRecorder::start() { |
michael@0 | 30 | mStarted = true; |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | return status; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | sp<MediaSource> GonkRecorder::createAudioSource() { |
michael@0 | 37 | |
michael@0 | 38 | - bool tunneledSource = false; |
michael@0 | 39 | - const char *tunnelMime; |
michael@0 | 40 | - { |
michael@0 | 41 | - AudioParameter param; |
michael@0 | 42 | - String8 key("tunneled-input-formats"); |
michael@0 | 43 | - param.add( key, String8("get") ); |
michael@0 | 44 | - String8 valueStr = AudioSystem::getParameters( 0, param.toString()); |
michael@0 | 45 | - AudioParameter result(valueStr); |
michael@0 | 46 | - int value; |
michael@0 | 47 | - if ( mAudioEncoder == AUDIO_ENCODER_AMR_NB && |
michael@0 | 48 | - result.getInt(String8("AMR"),value) == NO_ERROR ) { |
michael@0 | 49 | - tunneledSource = true; |
michael@0 | 50 | - tunnelMime = MEDIA_MIMETYPE_AUDIO_AMR_NB; |
michael@0 | 51 | - } |
michael@0 | 52 | - else if ( mAudioEncoder == AUDIO_ENCODER_QCELP && |
michael@0 | 53 | - result.getInt(String8("QCELP"),value) == NO_ERROR ) { |
michael@0 | 54 | - tunneledSource = true; |
michael@0 | 55 | - tunnelMime = MEDIA_MIMETYPE_AUDIO_QCELP; |
michael@0 | 56 | - } |
michael@0 | 57 | - else if ( mAudioEncoder == AUDIO_ENCODER_EVRC && |
michael@0 | 58 | - result.getInt(String8("EVRC"),value) == NO_ERROR ) { |
michael@0 | 59 | - tunneledSource = true; |
michael@0 | 60 | - tunnelMime = MEDIA_MIMETYPE_AUDIO_EVRC; |
michael@0 | 61 | - } |
michael@0 | 62 | - } |
michael@0 | 63 | - |
michael@0 | 64 | - if ( tunneledSource ) { |
michael@0 | 65 | - sp<AudioSource> audioSource = NULL; |
michael@0 | 66 | - sp<MetaData> meta = new MetaData; |
michael@0 | 67 | - meta->setInt32(kKeyChannelCount, mAudioChannels); |
michael@0 | 68 | - meta->setInt32(kKeySampleRate, mSampleRate); |
michael@0 | 69 | - meta->setInt32(kKeyBitRate, mAudioBitRate); |
michael@0 | 70 | - if (mAudioTimeScale > 0) { |
michael@0 | 71 | - meta->setInt32(kKeyTimeScale, mAudioTimeScale); |
michael@0 | 72 | - } |
michael@0 | 73 | - meta->setCString( kKeyMIMEType, tunnelMime ); |
michael@0 | 74 | - audioSource = new AudioSource( mAudioSource, meta); |
michael@0 | 75 | - return audioSource->initCheck( ) == OK ? audioSource : NULL; |
michael@0 | 76 | - } |
michael@0 | 77 | - |
michael@0 | 78 | sp<AudioSource> audioSource = |
michael@0 | 79 | new AudioSource( |
michael@0 | 80 | mAudioSource, |
michael@0 | 81 | mSampleRate, |
michael@0 | 82 | mAudioChannels); |
michael@0 | 83 | |
michael@0 | 84 | status_t err = audioSource->initCheck(); |
michael@0 | 85 | |
michael@0 | 86 | @@ -1226,56 +1186,33 @@ status_t GonkRecorder::setupVideoEncoder |
michael@0 | 87 | |
michael@0 | 88 | default: |
michael@0 | 89 | CHECK(!"Should not be here, unsupported video encoding."); |
michael@0 | 90 | break; |
michael@0 | 91 | } |
michael@0 | 92 | |
michael@0 | 93 | sp<MetaData> meta = cameraSource->getFormat(); |
michael@0 | 94 | |
michael@0 | 95 | - int32_t width, height, stride, sliceHeight, colorFormat, hfr, is3D; |
michael@0 | 96 | + int32_t width, height, stride, sliceHeight, colorFormat; |
michael@0 | 97 | CHECK(meta->findInt32(kKeyWidth, &width)); |
michael@0 | 98 | CHECK(meta->findInt32(kKeyHeight, &height)); |
michael@0 | 99 | CHECK(meta->findInt32(kKeyStride, &stride)); |
michael@0 | 100 | CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight)); |
michael@0 | 101 | CHECK(meta->findInt32(kKeyColorFormat, &colorFormat)); |
michael@0 | 102 | - CHECK(meta->findInt32(kKeyHFR, &hfr)); |
michael@0 | 103 | - |
michael@0 | 104 | - if(hfr) { |
michael@0 | 105 | - mMaxFileDurationUs = mMaxFileDurationUs * (hfr/mFrameRate); |
michael@0 | 106 | - } |
michael@0 | 107 | - |
michael@0 | 108 | |
michael@0 | 109 | enc_meta->setInt32(kKeyWidth, width); |
michael@0 | 110 | enc_meta->setInt32(kKeyHeight, height); |
michael@0 | 111 | enc_meta->setInt32(kKeyIFramesInterval, mIFramesIntervalSec); |
michael@0 | 112 | enc_meta->setInt32(kKeyStride, stride); |
michael@0 | 113 | enc_meta->setInt32(kKeySliceHeight, sliceHeight); |
michael@0 | 114 | enc_meta->setInt32(kKeyColorFormat, colorFormat); |
michael@0 | 115 | - enc_meta->setInt32(kKeyHFR, hfr); |
michael@0 | 116 | if (mVideoTimeScale > 0) { |
michael@0 | 117 | enc_meta->setInt32(kKeyTimeScale, mVideoTimeScale); |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | - char mDeviceName[100]; |
michael@0 | 121 | - property_get("ro.board.platform",mDeviceName,"0"); |
michael@0 | 122 | - if(!strncmp(mDeviceName, "msm7627a", 8)) { |
michael@0 | 123 | - if(hfr && (width * height > 432*240)) { |
michael@0 | 124 | - LOGE("HFR mode is supported only upto WQVGA resolution"); |
michael@0 | 125 | - return INVALID_OPERATION; |
michael@0 | 126 | - } |
michael@0 | 127 | - } |
michael@0 | 128 | - else { |
michael@0 | 129 | - if(hfr && ((mVideoEncoder != VIDEO_ENCODER_H264) || (width * height > 800*480))) { |
michael@0 | 130 | - LOGE("HFR mode is supported only upto WVGA and H264 codec."); |
michael@0 | 131 | - return INVALID_OPERATION; |
michael@0 | 132 | - } |
michael@0 | 133 | - } |
michael@0 | 134 | - |
michael@0 | 135 | - |
michael@0 | 136 | /* |
michael@0 | 137 | * can set profile from the app as a parameter. |
michael@0 | 138 | * For the mean time, set from shell |
michael@0 | 139 | */ |
michael@0 | 140 | |
michael@0 | 141 | char value[PROPERTY_VALUE_MAX]; |
michael@0 | 142 | bool customProfile = false; |
michael@0 | 143 | |
michael@0 | 144 | @@ -1322,19 +1259,16 @@ status_t GonkRecorder::setupVideoEncoder |
michael@0 | 145 | } |
michael@0 | 146 | |
michael@0 | 147 | if (mVideoEncoderProfile != -1) { |
michael@0 | 148 | enc_meta->setInt32(kKeyVideoProfile, mVideoEncoderProfile); |
michael@0 | 149 | } |
michael@0 | 150 | if (mVideoEncoderLevel != -1) { |
michael@0 | 151 | enc_meta->setInt32(kKeyVideoLevel, mVideoEncoderLevel); |
michael@0 | 152 | } |
michael@0 | 153 | - if (meta->findInt32(kKey3D, &is3D)) { |
michael@0 | 154 | - enc_meta->setInt32(kKey3D, is3D); |
michael@0 | 155 | - } |
michael@0 | 156 | |
michael@0 | 157 | uint32_t encoder_flags = 0; |
michael@0 | 158 | if (mIsMetaDataStoredInVideoBuffers) { |
michael@0 | 159 | LOGW("Camera source supports metadata mode, create OMXCodec for metadata"); |
michael@0 | 160 | encoder_flags |= OMXCodec::kHardwareCodecsOnly; |
michael@0 | 161 | encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers; |
michael@0 | 162 | encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime; |
michael@0 | 163 | } |