Bug 803471 - Part 5d - Cange GonkRecorder to use GonkCameraHardware. r=mhabicher
authorSotaro Ikeda <sikeda@mozilla.com>
Fri, 08 Mar 2013 14:43:33 -0500
changeset 124266 7f0a8b55cd6829d18d85aaf962e73543991d6fd9
parent 124265 c7f37db7d7384244236b439f57dddcb8cdc9c60b
child 124267 855c69ddfc870b7becf60b468ed0ed4b327d8028
push id24412
push userryanvm@gmail.com
push dateSun, 10 Mar 2013 00:01:53 +0000
treeherdermozilla-central@9e6232e86000 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhabicher
bugs803471
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 803471 - Part 5d - Cange GonkRecorder to use GonkCameraHardware. r=mhabicher
dom/camera/GonkRecorder.cpp
dom/camera/GonkRecorder.h
--- a/dom/camera/GonkRecorder.cpp
+++ b/dom/camera/GonkRecorder.cpp
@@ -10,20 +10,17 @@
  *
  * 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.
  */
 
-//#define LOG_NDEBUG 0
-#define LOG_TAG "GonkRecorder"
 
-#include <utils/Log.h>
 #include <media/AudioParameter.h>
 #include "GonkRecorder.h"
 
 #include <media/stagefright/AudioSource.h>
 #include <media/stagefright/AMRWriter.h>
 #include <media/stagefright/MPEG2TSWriter.h>
 #include <media/stagefright/MPEG4Writer.h>
 #include <media/stagefright/MediaDebug.h>
@@ -39,47 +36,50 @@
 #include <ctype.h>
 #include <unistd.h>
 
 #include <system/audio.h>
 
 #include "ARTPWriter.h"
 
 #include <cutils/properties.h>
+
+#include "CameraCommon.h"
 #include "GonkCameraSource.h"
 
 namespace android {
 
 GonkRecorder::GonkRecorder()
     : mWriter(NULL),
       mOutputFd(-1),
       mAudioSource(AUDIO_SOURCE_CNT),
       mVideoSource(VIDEO_SOURCE_LIST_END),
       mStarted(false),
       mDisableAudio(false) {
 
-    LOGV("Constructor");
+    DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
     reset();
 }
 
 GonkRecorder::~GonkRecorder() {
-    LOGV("Destructor");
+    DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
     stop();
 }
 
 status_t GonkRecorder::init() {
-    LOGV("init");
+    DOM_CAMERA_LOGT("%s:%d : this=%p\n", __func__, __LINE__, this);
     return OK;
 }
 
 status_t GonkRecorder::setAudioSource(audio_source_t as) {
-    LOGV("setAudioSource: %d", as);
+    DOM_CAMERA_LOGI("%s: %d", __func__, as);
+
     if (as < AUDIO_SOURCE_DEFAULT ||
         as >= AUDIO_SOURCE_CNT) {
-        LOGE("Invalid audio source: %d", as);
+        DOM_CAMERA_LOGE("Invalid audio source: %d", as);
         return BAD_VALUE;
     }
 
     if (mDisableAudio) {
         return OK;
     }
 
     if (as == AUDIO_SOURCE_DEFAULT) {
@@ -87,54 +87,54 @@ status_t GonkRecorder::setAudioSource(au
     } else {
         mAudioSource = as;
     }
 
     return OK;
 }
 
 status_t GonkRecorder::setVideoSource(video_source vs) {
-    LOGV("setVideoSource: %d", vs);
+    DOM_CAMERA_LOGI("%s: %d", __func__, vs);
     if (vs < VIDEO_SOURCE_DEFAULT ||
         vs >= VIDEO_SOURCE_LIST_END) {
-        LOGE("Invalid video source: %d", vs);
+        DOM_CAMERA_LOGE("Invalid video source: %d", vs);
         return BAD_VALUE;
     }
 
     if (vs == VIDEO_SOURCE_DEFAULT) {
         mVideoSource = VIDEO_SOURCE_CAMERA;
     } else {
         mVideoSource = vs;
     }
 
     return OK;
 }
 
 status_t GonkRecorder::setOutputFormat(output_format of) {
-    LOGV("setOutputFormat: %d", of);
+    DOM_CAMERA_LOGI("%s: %d", __func__, of);
     if (of < OUTPUT_FORMAT_DEFAULT ||
         of >= OUTPUT_FORMAT_LIST_END) {
-        LOGE("Invalid output format: %d", of);
+        DOM_CAMERA_LOGE("Invalid output format: %d", of);
         return BAD_VALUE;
     }
 
     if (of == OUTPUT_FORMAT_DEFAULT) {
         mOutputFormat = OUTPUT_FORMAT_THREE_GPP;
     } else {
         mOutputFormat = of;
     }
 
     return OK;
 }
 
 status_t GonkRecorder::setAudioEncoder(audio_encoder ae) {
-    LOGV("setAudioEncoder: %d", ae);
+    DOM_CAMERA_LOGI("%s: %d", __func__, ae);
     if (ae < AUDIO_ENCODER_DEFAULT ||
         ae >= AUDIO_ENCODER_LIST_END) {
-        LOGE("Invalid audio encoder: %d", ae);
+        DOM_CAMERA_LOGE("Invalid audio encoder: %d", ae);
         return BAD_VALUE;
     }
 
     if (mDisableAudio) {
         return OK;
     }
 
     if (ae == AUDIO_ENCODER_DEFAULT) {
@@ -142,76 +142,76 @@ status_t GonkRecorder::setAudioEncoder(a
     } else {
         mAudioEncoder = ae;
     }
 
     return OK;
 }
 
 status_t GonkRecorder::setVideoEncoder(video_encoder ve) {
-    LOGV("setVideoEncoder: %d", ve);
+    DOM_CAMERA_LOGI("%s: %d", __func__, ve);
     if (ve < VIDEO_ENCODER_DEFAULT ||
         ve >= VIDEO_ENCODER_LIST_END) {
-        LOGE("Invalid video encoder: %d", ve);
+        DOM_CAMERA_LOGE("Invalid video encoder: %d", ve);
         return BAD_VALUE;
     }
 
     if (ve == VIDEO_ENCODER_DEFAULT) {
         mVideoEncoder = VIDEO_ENCODER_H263;
     } else {
         mVideoEncoder = ve;
     }
 
     return OK;
 }
 
 status_t GonkRecorder::setVideoSize(int width, int height) {
-    LOGV("setVideoSize: %dx%d", width, height);
+    DOM_CAMERA_LOGI("%s: %dx%d", __func__, width, height);
     if (width <= 0 || height <= 0) {
-        LOGE("Invalid video size: %dx%d", width, height);
+        DOM_CAMERA_LOGE("Invalid video size: %dx%d", width, height);
         return BAD_VALUE;
     }
 
     // Additional check on the dimension will be performed later
     mVideoWidth = width;
     mVideoHeight = height;
 
     return OK;
 }
 
 status_t GonkRecorder::setVideoFrameRate(int frames_per_second) {
-    LOGV("setVideoFrameRate: %d", frames_per_second);
+    DOM_CAMERA_LOGI("%s: %d", __func__, frames_per_second);
     if ((frames_per_second <= 0 && frames_per_second != -1) ||
         frames_per_second > 120) {
-        LOGE("Invalid video frame rate: %d", frames_per_second);
+        DOM_CAMERA_LOGE("Invalid video frame rate: %d", frames_per_second);
         return BAD_VALUE;
     }
 
     // Additional check on the frame rate will be performed later
     mFrameRate = frames_per_second;
 
     return OK;
 }
 
 status_t GonkRecorder::setOutputFile(const char *path) {
-    LOGE("setOutputFile(const char*) must not be called");
+    DOM_CAMERA_LOGE("setOutputFile(const char*) must not be called");
     // We don't actually support this at all, as the media_server process
     // no longer has permissions to create files.
 
     return -EPERM;
 }
 
 status_t GonkRecorder::setOutputFile(int fd, int64_t offset, int64_t length) {
-    LOGV("setOutputFile: %d, %lld, %lld", fd, offset, length);
+    DOM_CAMERA_LOGI("%s: %d, %lld, %lld", __func__, fd, offset, length);
     // These don't make any sense, do they?
     CHECK_EQ(offset, 0);
     CHECK_EQ(length, 0);
 
     if (fd < 0) {
-        LOGE("Invalid file descriptor: %d", fd);
+        DOM_CAMERA_LOGE("Invalid file descriptor: %d", fd);
         return -EBADF;
     }
 
     if (mOutputFd >= 0) {
         ::close(mOutputFd);
     }
     mOutputFd = dup(fd);
 
@@ -269,229 +269,229 @@ static void TrimString(String8 *s) {
     while (i > leading_space && isspace(data[i - 1])) {
         --i;
     }
 
     s->setTo(String8(&data[leading_space], i - leading_space));
 }
 
 status_t GonkRecorder::setParamAudioSamplingRate(int32_t sampleRate) {
-    LOGV("setParamAudioSamplingRate: %d", sampleRate);
+    DOM_CAMERA_LOGI("%s: %d", __func__, sampleRate);
     if (sampleRate <= 0) {
-        LOGE("Invalid audio sampling rate: %d", sampleRate);
+        DOM_CAMERA_LOGE("Invalid audio sampling rate: %d", sampleRate);
         return BAD_VALUE;
     }
 
     // Additional check on the sample rate will be performed later.
     mSampleRate = sampleRate;
     return OK;
 }
 
 status_t GonkRecorder::setParamAudioNumberOfChannels(int32_t channels) {
-    LOGV("setParamAudioNumberOfChannels: %d", channels);
+    DOM_CAMERA_LOGI("%s: %d", __func__, channels);
     if (channels <= 0 || channels >= 3) {
-        LOGE("Invalid number of audio channels: %d", channels);
+        DOM_CAMERA_LOGE("Invalid number of audio channels: %d", channels);
         return BAD_VALUE;
     }
 
     // Additional check on the number of channels will be performed later.
     mAudioChannels = channels;
     return OK;
 }
 
 status_t GonkRecorder::setParamAudioEncodingBitRate(int32_t bitRate) {
-    LOGV("setParamAudioEncodingBitRate: %d", bitRate);
+    DOM_CAMERA_LOGI("%s: %d", __func__, bitRate);
     if (bitRate <= 0) {
-        LOGE("Invalid audio encoding bit rate: %d", bitRate);
+        DOM_CAMERA_LOGE("Invalid audio encoding bit rate: %d", bitRate);
         return BAD_VALUE;
     }
 
     // The target bit rate may not be exactly the same as the requested.
     // It depends on many factors, such as rate control, and the bit rate
     // range that a specific encoder supports. The mismatch between the
     // the target and requested bit rate will NOT be treated as an error.
     mAudioBitRate = bitRate;
     return OK;
 }
 
 status_t GonkRecorder::setParamVideoEncodingBitRate(int32_t bitRate) {
-    LOGV("setParamVideoEncodingBitRate: %d", bitRate);
+    DOM_CAMERA_LOGI("%s: %d", __func__, bitRate);
     if (bitRate <= 0) {
-        LOGE("Invalid video encoding bit rate: %d", bitRate);
+        DOM_CAMERA_LOGE("Invalid video encoding bit rate: %d", bitRate);
         return BAD_VALUE;
     }
 
     // The target bit rate may not be exactly the same as the requested.
     // It depends on many factors, such as rate control, and the bit rate
     // range that a specific encoder supports. The mismatch between the
     // the target and requested bit rate will NOT be treated as an error.
     mVideoBitRate = bitRate;
     return OK;
 }
 
 // Always rotate clockwise, and only support 0, 90, 180 and 270 for now.
 status_t GonkRecorder::setParamVideoRotation(int32_t degrees) {
-    LOGV("setParamVideoRotation: %d", degrees);
+    DOM_CAMERA_LOGI("%s: %d", __func__, degrees);
     if (degrees < 0 || degrees % 90 != 0) {
-        LOGE("Unsupported video rotation angle: %d", degrees);
+        DOM_CAMERA_LOGE("Unsupported video rotation angle: %d", degrees);
         return BAD_VALUE;
     }
     mRotationDegrees = degrees % 360;
     return OK;
 }
 
 status_t GonkRecorder::setParamMaxFileDurationUs(int64_t timeUs) {
-    LOGV("setParamMaxFileDurationUs: %lld us", timeUs);
+    DOM_CAMERA_LOGI("%s: %lld us", __func__, timeUs);
 
     // This is meant for backward compatibility for MediaRecorder.java
     if (timeUs <= 0) {
-        LOGW("Max file duration is not positive: %lld us. Disabling duration limit.", timeUs);
+        DOM_CAMERA_LOGW("Max file duration is not positive: %lld us. Disabling duration limit.", timeUs);
         timeUs = 0; // Disable the duration limit for zero or negative values.
     } else if (timeUs <= 100000LL) {  // XXX: 100 milli-seconds
-        LOGE("Max file duration is too short: %lld us", timeUs);
+        DOM_CAMERA_LOGE("Max file duration is too short: %lld us", timeUs);
         return BAD_VALUE;
     }
 
     if (timeUs <= 15 * 1000000LL) {
-        LOGW("Target duration (%lld us) too short to be respected", timeUs);
+        DOM_CAMERA_LOGW("Target duration (%lld us) too short to be respected", timeUs);
     }
     mMaxFileDurationUs = timeUs;
     return OK;
 }
 
 status_t GonkRecorder::setParamMaxFileSizeBytes(int64_t bytes) {
-    LOGV("setParamMaxFileSizeBytes: %lld bytes", bytes);
+    DOM_CAMERA_LOGI("%s: %lld bytes", __func__, bytes);
 
     // This is meant for backward compatibility for MediaRecorder.java
     if (bytes <= 0) {
-        LOGW("Max file size is not positive: %lld bytes. "
+        DOM_CAMERA_LOGW("Max file size is not positive: %lld bytes. "
              "Disabling file size limit.", bytes);
         bytes = 0; // Disable the file size limit for zero or negative values.
     } else if (bytes <= 1024) {  // XXX: 1 kB
-        LOGE("Max file size is too small: %lld bytes", bytes);
+        DOM_CAMERA_LOGE("Max file size is too small: %lld bytes", bytes);
         return BAD_VALUE;
     }
 
     if (bytes <= 100 * 1024) {
-        LOGW("Target file size (%lld bytes) is too small to be respected", bytes);
+        DOM_CAMERA_LOGW("Target file size (%lld bytes) is too small to be respected", bytes);
     }
 
     if (bytes >= 0xffffffffLL) {
-        LOGW("Target file size (%lld bytes) too larger than supported, clip to 4GB", bytes);
+        DOM_CAMERA_LOGW("Target file size (%lld bytes) too larger than supported, clip to 4GB", bytes);
         bytes = 0xffffffffLL;
     }
 
     mMaxFileSizeBytes = bytes;
     return OK;
 }
 
 status_t GonkRecorder::setParamInterleaveDuration(int32_t durationUs) {
-    LOGV("setParamInterleaveDuration: %d", durationUs);
+    DOM_CAMERA_LOGI("%s: %d", __func__, durationUs);
     if (durationUs <= 500000) {           //  500 ms
         // If interleave duration is too small, it is very inefficient to do
         // interleaving since the metadata overhead will count for a significant
         // portion of the saved contents
-        LOGE("Audio/video interleave duration is too small: %d us", durationUs);
+        DOM_CAMERA_LOGE("Audio/video interleave duration is too small: %d us", durationUs);
         return BAD_VALUE;
     } else if (durationUs >= 10000000) {  // 10 seconds
         // If interleaving duration is too large, it can cause the recording
         // session to use too much memory since we have to save the output
         // data before we write them out
-        LOGE("Audio/video interleave duration is too large: %d us", durationUs);
+        DOM_CAMERA_LOGE("Audio/video interleave duration is too large: %d us", durationUs);
         return BAD_VALUE;
     }
     mInterleaveDurationUs = durationUs;
     return OK;
 }
 
 // If seconds <  0, only the first frame is I frame, and rest are all P frames
 // If seconds == 0, all frames are encoded as I frames. No P frames
 // If seconds >  0, it is the time spacing (seconds) between 2 neighboring I frames
 status_t GonkRecorder::setParamVideoIFramesInterval(int32_t seconds) {
-    LOGV("setParamVideoIFramesInterval: %d seconds", seconds);
+    DOM_CAMERA_LOGI("%s: %d seconds", __func__, seconds);
     mIFramesIntervalSec = seconds;
     return OK;
 }
 
 status_t GonkRecorder::setParam64BitFileOffset(bool use64Bit) {
-    LOGV("setParam64BitFileOffset: %s",
+    DOM_CAMERA_LOGI("%s: %s", __func__,
         use64Bit? "use 64 bit file offset": "use 32 bit file offset");
     mUse64BitFileOffset = use64Bit;
     return OK;
 }
 
 status_t GonkRecorder::setParamVideoCameraId(int32_t cameraId) {
-    LOGV("setParamVideoCameraId: %d", cameraId);
+    DOM_CAMERA_LOGI("%s: %d", __func__, cameraId);
     if (cameraId < 0) {
         return BAD_VALUE;
     }
     mCameraId = cameraId;
     return OK;
 }
 
 status_t GonkRecorder::setParamTrackTimeStatus(int64_t timeDurationUs) {
-    LOGV("setParamTrackTimeStatus: %lld", timeDurationUs);
+    DOM_CAMERA_LOGI("%s: %lld", __func__, timeDurationUs);
     if (timeDurationUs < 20000) {  // Infeasible if shorter than 20 ms?
-        LOGE("Tracking time duration too short: %lld us", timeDurationUs);
+        DOM_CAMERA_LOGE("Tracking time duration too short: %lld us", timeDurationUs);
         return BAD_VALUE;
     }
     mTrackEveryTimeDurationUs = timeDurationUs;
     return OK;
 }
 
 status_t GonkRecorder::setParamVideoEncoderProfile(int32_t profile) {
-    LOGV("setParamVideoEncoderProfile: %d", profile);
+    DOM_CAMERA_LOGI("%s: %d", __func__, profile);
 
     // Additional check will be done later when we load the encoder.
     // For now, we are accepting values defined in OpenMAX IL.
     mVideoEncoderProfile = profile;
     return OK;
 }
 
 status_t GonkRecorder::setParamVideoEncoderLevel(int32_t level) {
-    LOGV("setParamVideoEncoderLevel: %d", level);
+    DOM_CAMERA_LOGI("%s: %d", __func__, level);
 
     // Additional check will be done later when we load the encoder.
     // For now, we are accepting values defined in OpenMAX IL.
     mVideoEncoderLevel = level;
     return OK;
 }
 
 status_t GonkRecorder::setParamMovieTimeScale(int32_t timeScale) {
-    LOGV("setParamMovieTimeScale: %d", timeScale);
+    DOM_CAMERA_LOGI("%s: %d", __func__, timeScale);
 
     // The range is set to be the same as the audio's time scale range
     // since audio's time scale has a wider range.
     if (timeScale < 600 || timeScale > 96000) {
-        LOGE("Time scale (%d) for movie is out of range [600, 96000]", timeScale);
+        DOM_CAMERA_LOGE("Time scale (%d) for movie is out of range [600, 96000]", timeScale);
         return BAD_VALUE;
     }
     mMovieTimeScale = timeScale;
     return OK;
 }
 
 status_t GonkRecorder::setParamVideoTimeScale(int32_t timeScale) {
-    LOGV("setParamVideoTimeScale: %d", timeScale);
+    DOM_CAMERA_LOGI("%s: %d", __func__, timeScale);
 
     // 60000 is chosen to make sure that each video frame from a 60-fps
     // video has 1000 ticks.
     if (timeScale < 600 || timeScale > 60000) {
-        LOGE("Time scale (%d) for video is out of range [600, 60000]", timeScale);
+        DOM_CAMERA_LOGE("Time scale (%d) for video is out of range [600, 60000]", timeScale);
         return BAD_VALUE;
     }
     mVideoTimeScale = timeScale;
     return OK;
 }
 
 status_t GonkRecorder::setParamAudioTimeScale(int32_t timeScale) {
-    LOGV("setParamAudioTimeScale: %d", timeScale);
+    DOM_CAMERA_LOGI("%s: %d", __func__, timeScale);
 
     // 96000 Hz is the highest sampling rate support in AAC.
     if (timeScale < 600 || timeScale > 96000) {
-        LOGE("Time scale (%d) for audio is out of range [600, 96000]", timeScale);
+        DOM_CAMERA_LOGE("Time scale (%d) for audio is out of range [600, 96000]", timeScale);
         return BAD_VALUE;
     }
     mAudioTimeScale = timeScale;
     return OK;
 }
 
 status_t GonkRecorder::setParamGeoDataLongitude(
     int64_t longitudex10000) {
@@ -510,17 +510,17 @@ status_t GonkRecorder::setParamGeoDataLa
         return BAD_VALUE;
     }
     mLatitudex10000 = latitudex10000;
     return OK;
 }
 
 status_t GonkRecorder::setParameter(
         const String8 &key, const String8 &value) {
-    LOGV("setParameter: key (%s) => value (%s)", key.string(), value.string());
+    DOM_CAMERA_LOGI("%s: key (%s) => value (%s)", __func__, key.string(), value.string());
     if (key == "max-duration") {
         int64_t max_duration_ms;
         if (safe_strtoi64(value.string(), &max_duration_ms)) {
             return setParamMaxFileDurationUs(1000LL * max_duration_ms);
         }
     } else if (key == "max-filesize") {
         int64_t max_filesize_bytes;
         if (safe_strtoi64(value.string(), &max_filesize_bytes)) {
@@ -607,35 +607,35 @@ status_t GonkRecorder::setParameter(
             return setParamVideoCameraId(cameraId);
         }
     } else if (key == "video-param-time-scale") {
         int32_t timeScale;
         if (safe_strtoi32(value.string(), &timeScale)) {
             return setParamVideoTimeScale(timeScale);
         }
     } else {
-        LOGE("setParameter: failed to find key %s", key.string());
+        DOM_CAMERA_LOGE("setParameter: failed to find key %s", key.string());
     }
     return BAD_VALUE;
 }
 
 status_t GonkRecorder::setParameters(const String8 &params) {
-    LOGV("setParameters: %s", params.string());
+    DOM_CAMERA_LOGI("%s: %s", __func__, params.string());
     const char *cparams = params.string();
     const char *key_start = cparams;
     for (;;) {
         const char *equal_pos = strchr(key_start, '=');
         if (equal_pos == NULL) {
-            LOGE("Parameters %s miss a value", cparams);
+            DOM_CAMERA_LOGE("Parameters %s miss a value", cparams);
             return BAD_VALUE;
         }
         String8 key(key_start, equal_pos - key_start);
         TrimString(&key);
         if (key.length() == 0) {
-            LOGE("Parameters %s contains an empty key", cparams);
+            DOM_CAMERA_LOGE("Parameters %s contains an empty key", cparams);
             return BAD_VALUE;
         }
         const char *value_start = equal_pos + 1;
         const char *semicolon_pos = strchr(value_start, ';');
         String8 value;
         if (semicolon_pos == NULL) {
             value.setTo(value_start);
         } else {
@@ -654,35 +654,35 @@ status_t GonkRecorder::setParameters(con
 
 status_t GonkRecorder::setListener(const sp<IMediaRecorderClient> &listener) {
     mListener = listener;
 
     return OK;
 }
 
 status_t GonkRecorder::prepare() {
-  LOGV(" %s E", __func__ );
+  DOM_CAMERA_LOGI(" %s E", __func__ );
 
   if(mVideoSource != VIDEO_SOURCE_LIST_END && mVideoEncoder != VIDEO_ENCODER_LIST_END && mVideoHeight && mVideoWidth &&             /*Video recording*/
          (mMaxFileDurationUs <=0 ||             /*Max duration is not set*/
          (mVideoHeight * mVideoWidth < 720 * 1280 && mMaxFileDurationUs > 30*60*1000*1000) ||
          (mVideoHeight * mVideoWidth >= 720 * 1280 && mMaxFileDurationUs > 10*60*1000*1000))) {
     /*Above Check can be further optimized for lower resolutions to reduce file size*/
-    LOGV("File is huge so setting 64 bit file offsets");
+    DOM_CAMERA_LOGI("File is huge so setting 64 bit file offsets");
     setParam64BitFileOffset(true);
   }
-  LOGV(" %s X", __func__ );
+  DOM_CAMERA_LOGI(" %s X", __func__ );
   return OK;
 }
 
 status_t GonkRecorder::start() {
     CHECK(mOutputFd >= 0);
 
     if (mWriter != NULL) {
-        LOGE("File writer is not available");
+        DOM_CAMERA_LOGE("File writer is not available");
         return UNKNOWN_ERROR;
     }
 
     status_t status = OK;
 
     switch (mOutputFormat) {
         case OUTPUT_FORMAT_DEFAULT:
         case OUTPUT_FORMAT_THREE_GPP:
@@ -694,17 +694,17 @@ status_t GonkRecorder::start() {
         case OUTPUT_FORMAT_AMR_WB:
             status = startAMRRecording();
             break;
 
         case OUTPUT_FORMAT_MPEG2TS:
             status = startMPEG2TSRecording();
 		    break;
         default:
-            LOGE("Unsupported output file format: %d", mOutputFormat);
+            DOM_CAMERA_LOGE("Unsupported output file format: %d", mOutputFormat);
             status = UNKNOWN_ERROR;
             break;
     }
 
     if ((status == OK) && (!mStarted)) {
         mStarted = true;
     }
 
@@ -717,17 +717,17 @@ sp<MediaSource> GonkRecorder::createAudi
         new AudioSource(
                 mAudioSource,
                 mSampleRate,
                 mAudioChannels);
 
     status_t err = audioSource->initCheck();
 
     if (err != OK) {
-        LOGE("audio source is not initialized");
+        DOM_CAMERA_LOGE("audio source is not initialized");
         return NULL;
     }
 
     sp<MetaData> encMeta = new MetaData;
     const char *mime;
     switch (mAudioEncoder) {
         case AUDIO_ENCODER_AMR_NB:
         case AUDIO_ENCODER_DEFAULT:
@@ -735,17 +735,17 @@ sp<MediaSource> GonkRecorder::createAudi
             break;
         case AUDIO_ENCODER_AMR_WB:
             mime = MEDIA_MIMETYPE_AUDIO_AMR_WB;
             break;
         case AUDIO_ENCODER_AAC:
             mime = MEDIA_MIMETYPE_AUDIO_AAC;
             break;
         default:
-            LOGE("Unknown audio encoder: %d", mAudioEncoder);
+            DOM_CAMERA_LOGE("Unknown audio encoder: %d", mAudioEncoder);
             return NULL;
     }
     encMeta->setCString(kKeyMIMEType, mime);
 
     int32_t maxInputSize;
     CHECK(audioSource->getFormat()->findInt32(
                 kKeyMaxInputSize, &maxInputSize));
 
@@ -773,40 +773,40 @@ sp<MediaSource> GonkRecorder::createAudi
 
 status_t GonkRecorder::startAMRRecording() {
     CHECK(mOutputFormat == OUTPUT_FORMAT_AMR_NB ||
           mOutputFormat == OUTPUT_FORMAT_AMR_WB);
 
     if (mOutputFormat == OUTPUT_FORMAT_AMR_NB) {
         if (mAudioEncoder != AUDIO_ENCODER_DEFAULT &&
             mAudioEncoder != AUDIO_ENCODER_AMR_NB) {
-            LOGE("Invalid encoder %d used for AMRNB recording",
+            DOM_CAMERA_LOGE("Invalid encoder %d used for AMRNB recording",
                     mAudioEncoder);
             return BAD_VALUE;
         }
     } else {  // mOutputFormat must be OUTPUT_FORMAT_AMR_WB
         if (mAudioEncoder != AUDIO_ENCODER_AMR_WB) {
-            LOGE("Invlaid encoder %d used for AMRWB recording",
+            DOM_CAMERA_LOGE("Invalid encoder %d used for AMRWB recording",
                     mAudioEncoder);
             return BAD_VALUE;
         }
     }
 
     mWriter = new AMRWriter(mOutputFd);
     status_t status = startRawAudioRecording();
     if (status != OK) {
         mWriter.clear();
         mWriter = NULL;
     }
     return status;
 }
 
 status_t GonkRecorder::startRawAudioRecording() {
     if (mAudioSource >= AUDIO_SOURCE_CNT) {
-        LOGE("Invalid audio source: %d", mAudioSource);
+        DOM_CAMERA_LOGE("Invalid audio source: %d", mAudioSource);
         return BAD_VALUE;
     }
 
     status_t status = BAD_VALUE;
     if (OK != (status = checkAudioEncoderCapabilities())) {
         return status;
     }
 
@@ -877,61 +877,61 @@ status_t GonkRecorder::startMPEG2TSRecor
     }
 
     mWriter = writer;
 
     return mWriter->start();
 }
 
 void GonkRecorder::clipVideoFrameRate() {
-    LOGV("clipVideoFrameRate: encoder %d", mVideoEncoder);
+    DOM_CAMERA_LOGI("%s: encoder %d", __func__, mVideoEncoder);
     int minFrameRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.fps.min", mVideoEncoder);
     int maxFrameRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.fps.max", mVideoEncoder);
     if (mFrameRate < minFrameRate && mFrameRate != -1) {
-        LOGW("Intended video encoding frame rate (%d fps) is too small"
+        DOM_CAMERA_LOGW("Intended video encoding frame rate (%d fps) is too small"
              " and will be set to (%d fps)", mFrameRate, minFrameRate);
         mFrameRate = minFrameRate;
     } else if (mFrameRate > maxFrameRate) {
-        LOGW("Intended video encoding frame rate (%d fps) is too large"
+        DOM_CAMERA_LOGW("Intended video encoding frame rate (%d fps) is too large"
              " and will be set to (%d fps)", mFrameRate, maxFrameRate);
         mFrameRate = maxFrameRate;
     }
 }
 
 void GonkRecorder::clipVideoBitRate() {
-    LOGV("clipVideoBitRate: encoder %d", mVideoEncoder);
+    DOM_CAMERA_LOGI("%s: encoder %d", __func__, mVideoEncoder);
     int minBitRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.bps.min", mVideoEncoder);
     int maxBitRate = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.bps.max", mVideoEncoder);
     if (mVideoBitRate < minBitRate) {
-        LOGW("Intended video encoding bit rate (%d bps) is too small"
+        DOM_CAMERA_LOGW("Intended video encoding bit rate (%d bps) is too small"
              " and will be set to (%d bps)", mVideoBitRate, minBitRate);
         mVideoBitRate = minBitRate;
     } else if (mVideoBitRate > maxBitRate) {
-        LOGW("Intended video encoding bit rate (%d bps) is too large"
+        DOM_CAMERA_LOGW("Intended video encoding bit rate (%d bps) is too large"
              " and will be set to (%d bps)", mVideoBitRate, maxBitRate);
         mVideoBitRate = maxBitRate;
     }
 }
 
 void GonkRecorder::clipVideoFrameWidth() {
-    LOGV("clipVideoFrameWidth: encoder %d", mVideoEncoder);
+    DOM_CAMERA_LOGI("%s: encoder %d", __func__, mVideoEncoder);
     int minFrameWidth = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.width.min", mVideoEncoder);
     int maxFrameWidth = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.width.max", mVideoEncoder);
     if (mVideoWidth < minFrameWidth) {
-        LOGW("Intended video encoding frame width (%d) is too small"
+        DOM_CAMERA_LOGW("Intended video encoding frame width (%d) is too small"
              " and will be set to (%d)", mVideoWidth, minFrameWidth);
         mVideoWidth = minFrameWidth;
     } else if (mVideoWidth > maxFrameWidth) {
-        LOGW("Intended video encoding frame width (%d) is too large"
+        DOM_CAMERA_LOGW("Intended video encoding frame width (%d) is too large"
              " and will be set to (%d)", mVideoWidth, maxFrameWidth);
         mVideoWidth = maxFrameWidth;
     }
 }
 
 status_t GonkRecorder::checkVideoEncoderCapabilities() {
         // Dont clip for time lapse capture as encoder will have enough
         // time to encode because of slow capture rate of time lapse.
@@ -941,17 +941,17 @@ status_t GonkRecorder::checkVideoEncoder
         clipVideoFrameHeight();
         setDefaultProfileIfNecessary();
     return OK;
 }
 
 // Set to use AVC baseline profile if the encoding parameters matches
 // CAMCORDER_QUALITY_LOW profile; this is for the sake of MMS service.
 void GonkRecorder::setDefaultProfileIfNecessary() {
-    LOGV("setDefaultProfileIfNecessary");
+    DOM_CAMERA_LOGI("%s", __func__);
 
     camcorder_quality quality = CAMCORDER_QUALITY_LOW;
 
     int64_t durationUs   = mEncoderProfiles->getCamcorderProfileParamByName(
                                 "duration", mCameraId, quality) * 1000000LL;
 
     int fileFormat       = mEncoderProfiles->getCamcorderProfileParamByName(
                                 "file.format", mCameraId, quality);
@@ -990,107 +990,107 @@ void GonkRecorder::setDefaultProfileIfNe
         videoFrameRate == mFrameRate &&
         videoFrameWidth == mVideoWidth &&
         videoFrameHeight == mVideoHeight &&
         audioCodec == mAudioEncoder &&
         audioBitRate == mAudioBitRate &&
         audioSampleRate == mSampleRate &&
         audioChannels == mAudioChannels) {
         if (videoCodec == VIDEO_ENCODER_H264) {
-            LOGI("Force to use AVC baseline profile");
+            DOM_CAMERA_LOGI("Force to use AVC baseline profile");
             setParamVideoEncoderProfile(OMX_VIDEO_AVCProfileBaseline);
         }
     }
 }
 
 status_t GonkRecorder::checkAudioEncoderCapabilities() {
     clipAudioBitRate();
     clipAudioSampleRate();
     clipNumberOfAudioChannels();
     return OK;
 }
 
 void GonkRecorder::clipAudioBitRate() {
-    LOGV("clipAudioBitRate: encoder %d", mAudioEncoder);
+    DOM_CAMERA_LOGI("%s: encoder %d", __func__, mAudioEncoder);
 
     int minAudioBitRate =
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.bps.min", mAudioEncoder);
     if (mAudioBitRate < minAudioBitRate) {
-        LOGW("Intended audio encoding bit rate (%d) is too small"
+        DOM_CAMERA_LOGW("Intended audio encoding bit rate (%d) is too small"
             " and will be set to (%d)", mAudioBitRate, minAudioBitRate);
         mAudioBitRate = minAudioBitRate;
     }
 
     int maxAudioBitRate =
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.bps.max", mAudioEncoder);
     if (mAudioBitRate > maxAudioBitRate) {
-        LOGW("Intended audio encoding bit rate (%d) is too large"
+        DOM_CAMERA_LOGW("Intended audio encoding bit rate (%d) is too large"
             " and will be set to (%d)", mAudioBitRate, maxAudioBitRate);
         mAudioBitRate = maxAudioBitRate;
     }
 }
 
 void GonkRecorder::clipAudioSampleRate() {
-    LOGV("clipAudioSampleRate: encoder %d", mAudioEncoder);
+    DOM_CAMERA_LOGI("%s: encoder %d", __func__, mAudioEncoder);
 
     int minSampleRate =
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.hz.min", mAudioEncoder);
     if (mSampleRate < minSampleRate) {
-        LOGW("Intended audio sample rate (%d) is too small"
+        DOM_CAMERA_LOGW("Intended audio sample rate (%d) is too small"
             " and will be set to (%d)", mSampleRate, minSampleRate);
         mSampleRate = minSampleRate;
     }
 
     int maxSampleRate =
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.hz.max", mAudioEncoder);
     if (mSampleRate > maxSampleRate) {
-        LOGW("Intended audio sample rate (%d) is too large"
+        DOM_CAMERA_LOGW("Intended audio sample rate (%d) is too large"
             " and will be set to (%d)", mSampleRate, maxSampleRate);
         mSampleRate = maxSampleRate;
     }
 }
 
 void GonkRecorder::clipNumberOfAudioChannels() {
-    LOGV("clipNumberOfAudioChannels: encoder %d", mAudioEncoder);
+    DOM_CAMERA_LOGI("%s: encoder %d", __func__, mAudioEncoder);
 
     int minChannels =
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.ch.min", mAudioEncoder);
     if (mAudioChannels < minChannels) {
-        LOGW("Intended number of audio channels (%d) is too small"
+        DOM_CAMERA_LOGW("Intended number of audio channels (%d) is too small"
             " and will be set to (%d)", mAudioChannels, minChannels);
         mAudioChannels = minChannels;
     }
 
     int maxChannels =
             mEncoderProfiles->getAudioEncoderParamByName(
                 "enc.aud.ch.max", mAudioEncoder);
     if (mAudioChannels > maxChannels) {
-        LOGW("Intended number of audio channels (%d) is too large"
+        DOM_CAMERA_LOGW("Intended number of audio channels (%d) is too large"
             " and will be set to (%d)", mAudioChannels, maxChannels);
         mAudioChannels = maxChannels;
     }
 }
 
 void GonkRecorder::clipVideoFrameHeight() {
-    LOGV("clipVideoFrameHeight: encoder %d", mVideoEncoder);
+    DOM_CAMERA_LOGI("%s: encoder %d", __func__, mVideoEncoder);
     int minFrameHeight = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.height.min", mVideoEncoder);
     int maxFrameHeight = mEncoderProfiles->getVideoEncoderParamByName(
                         "enc.vid.height.max", mVideoEncoder);
     if (mVideoHeight < minFrameHeight) {
-        LOGW("Intended video encoding frame height (%d) is too small"
+        DOM_CAMERA_LOGW("Intended video encoding frame height (%d) is too small"
              " and will be set to (%d)", mVideoHeight, minFrameHeight);
         mVideoHeight = minFrameHeight;
     } else if (mVideoHeight > maxFrameHeight) {
-        LOGW("Intended video encoding frame height (%d) is too large"
+        DOM_CAMERA_LOGW("Intended video encoding frame height (%d) is too large"
              " and will be set to (%d)", mVideoHeight, maxFrameHeight);
         mVideoHeight = maxFrameHeight;
     }
 }
 
 // Set up the appropriate MediaSource depending on the chosen option
 status_t GonkRecorder::setupMediaSource(
                       sp<MediaSource> *mediaSource) {
@@ -1122,34 +1122,34 @@ status_t GonkRecorder::setupCameraSource
     bool useMeta = true;
     char value[PROPERTY_VALUE_MAX];
     if (property_get("debug.camcorder.disablemeta", value, NULL) &&
             atoi(value)) {
       useMeta = false;
     }
 
     *cameraSource = GonkCameraSource::Create(
-                mCameraHandle, videoSize, mFrameRate, useMeta);
+                mCameraHw, videoSize, mFrameRate, useMeta);
     if (*cameraSource == NULL) {
         return UNKNOWN_ERROR;
     }
 
     if ((*cameraSource)->initCheck() != OK) {
         (*cameraSource).clear();
         *cameraSource = NULL;
         return NO_INIT;
     }
 
     // When frame rate is not set, the actual frame rate will be set to
     // the current frame rate being used.
     if (mFrameRate == -1) {
         int32_t frameRate = 0;
         CHECK ((*cameraSource)->getFormat()->findInt32(
                     kKeyFrameRate, &frameRate));
-        LOGI("Frame rate is not explicitly set. Use the current frame "
+        DOM_CAMERA_LOGI("Frame rate is not explicitly set. Use the current frame "
              "rate (%d fps)", frameRate);
         mFrameRate = frameRate;
     }
 
     CHECK(mFrameRate != -1);
 
     mIsMetaDataStoredInVideoBuffers =
         (*cameraSource)->isMetaDataStoredInVideoBuffers();
@@ -1216,76 +1216,76 @@ status_t GonkRecorder::setupVideoEncoder
         customProfile = true;
     }
 
     if (customProfile) {
         switch ( mVideoEncoder ) {
         case VIDEO_ENCODER_H264:
             if (strncmp("base", value, 4) == 0) {
                 mVideoEncoderProfile = OMX_VIDEO_AVCProfileBaseline;
-                LOGI("H264 Baseline Profile");
+                DOM_CAMERA_LOGI("H264 Baseline Profile");
             }
             else if (strncmp("main", value, 4) == 0) {
                 mVideoEncoderProfile = OMX_VIDEO_AVCProfileMain;
-                LOGI("H264 Main Profile");
+                DOM_CAMERA_LOGI("H264 Main Profile");
             }
             else if (strncmp("high", value, 4) == 0) {
                 mVideoEncoderProfile = OMX_VIDEO_AVCProfileHigh;
-                LOGI("H264 High Profile");
+                DOM_CAMERA_LOGI("H264 High Profile");
             }
             else {
-               LOGW("Unsupported H264 Profile");
+               DOM_CAMERA_LOGW("Unsupported H264 Profile");
             }
             break;
         case VIDEO_ENCODER_MPEG_4_SP:
             if (strncmp("simple", value, 5) == 0 ) {
                 mVideoEncoderProfile = OMX_VIDEO_MPEG4ProfileSimple;
-                LOGI("MPEG4 Simple profile");
+                DOM_CAMERA_LOGI("MPEG4 Simple profile");
             }
             else if (strncmp("asp", value, 3) == 0 ) {
                 mVideoEncoderProfile = OMX_VIDEO_MPEG4ProfileAdvancedSimple;
-                LOGI("MPEG4 Advanced Simple Profile");
+                DOM_CAMERA_LOGI("MPEG4 Advanced Simple Profile");
             }
             else {
-                LOGW("Unsupported MPEG4 Profile");
+                DOM_CAMERA_LOGW("Unsupported MPEG4 Profile");
             }
             break;
         default:
-            LOGW("No custom profile support for other codecs");
+            DOM_CAMERA_LOGW("No custom profile support for other codecs");
             break;
         }
     }
 
     if (mVideoEncoderProfile != -1) {
         enc_meta->setInt32(kKeyVideoProfile, mVideoEncoderProfile);
     }
     if (mVideoEncoderLevel != -1) {
         enc_meta->setInt32(kKeyVideoLevel, mVideoEncoderLevel);
     }
 
     uint32_t encoder_flags = 0;
     if (mIsMetaDataStoredInVideoBuffers) {
-        LOGW("Camera source supports metadata mode, create OMXCodec for metadata");
+        DOM_CAMERA_LOGW("Camera source supports metadata mode, create OMXCodec for metadata");
         encoder_flags |= OMXCodec::kHardwareCodecsOnly;
         encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
         encoder_flags |= OMXCodec::kOnlySubmitOneInputBufferAtOneTime;
     }
 
     // OMXClient::connect() always returns OK and abort's fatally if
     // it can't connect.
     OMXClient client;
     // CHECK_EQ causes an abort if the given condition fails.
     CHECK_EQ(client.connect(), OK);
 
     sp<MediaSource> encoder = OMXCodec::Create(
             client.interface(), enc_meta,
             true /* createEncoder */, cameraSource,
             NULL, encoder_flags);
     if (encoder == NULL) {
-        LOGW("Failed to create the encoder");
+        DOM_CAMERA_LOGW("Failed to create the encoder");
         // When the encoder fails to be created, we need
         // release the camera source due to the camera's lock
         // and unlock mechanism.
         cameraSource->stop();
         return UNKNOWN_ERROR;
     }
 
     *source = encoder;
@@ -1301,17 +1301,17 @@ status_t GonkRecorder::setupAudioEncoder
 
     switch(mAudioEncoder) {
         case AUDIO_ENCODER_AMR_NB:
         case AUDIO_ENCODER_AMR_WB:
         case AUDIO_ENCODER_AAC:
             break;
 
         default:
-            LOGE("Unsupported audio encoder: %d", mAudioEncoder);
+            DOM_CAMERA_LOGE("Unsupported audio encoder: %d", mAudioEncoder);
             return UNKNOWN_ERROR;
     }
 
     sp<MediaSource> audioEncoder = createAudioSource();
     if (audioEncoder == NULL) {
         return UNKNOWN_ERROR;
     }
 
@@ -1394,17 +1394,17 @@ void GonkRecorder::setupMPEG4MetaData(in
     }
     if (mTrackEveryTimeDurationUs > 0) {
         (*meta)->setInt64(kKeyTrackTimeStatus, mTrackEveryTimeDurationUs);
     }
 
     char value[PROPERTY_VALUE_MAX];
     if (property_get("debug.camcorder.rotation", value, 0) > 0 && atoi(value) >= 0) {
         mRotationDegrees = atoi(value);
-        LOGI("Setting rotation to %d", mRotationDegrees );
+        DOM_CAMERA_LOGI("Setting rotation to %d", mRotationDegrees );
     }
 
     if (mRotationDegrees != 0) {
         (*meta)->setInt32(kKeyRotation, mRotationDegrees);
     }
 }
 
 status_t GonkRecorder::startMPEG4Recording() {
@@ -1431,32 +1431,32 @@ status_t GonkRecorder::startMPEG4Recordi
     if (err != OK) {
         return err;
     }
 
     return OK;
 }
 
 status_t GonkRecorder::pause() {
-    LOGV("pause");
+    DOM_CAMERA_LOGI("%s", __func__);
     if (mWriter == NULL) {
         return UNKNOWN_ERROR;
     }
     mWriter->pause();
 
     if (mStarted) {
         mStarted = false;
     }
 
 
     return OK;
 }
 
 status_t GonkRecorder::stop() {
-    LOGV("stop");
+    DOM_CAMERA_LOGI("%s", __func__);
     status_t err = OK;
 
     if (mWriter != NULL) {
         err = mWriter->stop();
         mWriter.clear();
     }
 
     if (mOutputFd >= 0) {
@@ -1468,24 +1468,24 @@ status_t GonkRecorder::stop() {
         mStarted = false;
     }
 
 
     return err;
 }
 
 status_t GonkRecorder::close() {
-    LOGV("close");
+    DOM_CAMERA_LOGI("%s", __func__);
     stop();
 
     return OK;
 }
 
 status_t GonkRecorder::reset() {
-    LOGV("reset");
+    DOM_CAMERA_LOGI("%s", __func__);
     stop();
 
     // No audio or video source by default
     mAudioSource = AUDIO_SOURCE_CNT;
     mVideoSource = VIDEO_SOURCE_LIST_END;
 
     // Default parameters
     mOutputFormat  = OUTPUT_FORMAT_THREE_GPP;
@@ -1514,50 +1514,50 @@ status_t GonkRecorder::reset() {
     mTrackEveryTimeDurationUs = 0;
     mIsMetaDataStoredInVideoBuffers = false;
     mEncoderProfiles = MediaProfiles::getInstance();
     mRotationDegrees = 0;
     mLatitudex10000 = -3600000;
     mLongitudex10000 = -3600000;
 
     mOutputFd = -1;
-    mCameraHandle = -1;
+    mCameraHw.clear();
     //TODO: May need to register a listener eventually
     //if someone is interested in recorder events for now
     //default to no listener registered
     mListener = NULL;
 
     // Disable Audio Encoding
     char value[PROPERTY_VALUE_MAX];
     property_get("camcorder.debug.disableaudio", value, "0");
     if(atoi(value)) mDisableAudio = true;
 
     return OK;
 }
 
 status_t GonkRecorder::getMaxAmplitude(int *max) {
-    LOGV("getMaxAmplitude");
+    DOM_CAMERA_LOGI("%s", __func__);
 
     if (max == NULL) {
-        LOGE("Null pointer argument");
+        DOM_CAMERA_LOGE("Null pointer argument");
         return BAD_VALUE;
     }
 
     if (mAudioSourceNode != 0) {
         *max = mAudioSourceNode->getMaxAmplitude();
     } else {
         *max = 0;
     }
 
     return OK;
 }
 
 status_t GonkRecorder::dump(
         int fd, const Vector<String16>& args) const {
-    LOGV("dump");
+    DOM_CAMERA_LOGI("%s", __func__);
     const size_t SIZE = 256;
     char buffer[SIZE];
     String8 result;
     if (mWriter != 0) {
         mWriter->dump(fd, args);
     } else {
         snprintf(buffer, SIZE, "   No file writer\n");
         result.append(buffer);
@@ -1592,17 +1592,17 @@ status_t GonkRecorder::dump(
     snprintf(buffer, SIZE, "     Max amplitude: %d\n", mAudioSourceNode == 0? 0: mAudioSourceNode->getMaxAmplitude());
     result.append(buffer);
     snprintf(buffer, SIZE, "   Video\n");
     result.append(buffer);
     snprintf(buffer, SIZE, "     Source: %d\n", mVideoSource);
     result.append(buffer);
     snprintf(buffer, SIZE, "     Camera Id: %d\n", mCameraId);
     result.append(buffer);
-    snprintf(buffer, SIZE, "     Camera Handle: %d\n", mCameraHandle);
+    snprintf(buffer, SIZE, "     Camera object address: %p\n", mCameraHw.get());
     result.append(buffer);
     snprintf(buffer, SIZE, "     Start time offset (ms): %d\n", mStartTimeOffsetMs);
     result.append(buffer);
     snprintf(buffer, SIZE, "     Encoder: %d\n", mVideoEncoder);
     result.append(buffer);
     snprintf(buffer, SIZE, "     Encoder profile: %d\n", mVideoEncoderProfile);
     result.append(buffer);
     snprintf(buffer, SIZE, "     Encoder level: %d\n", mVideoEncoderLevel);
@@ -1614,17 +1614,14 @@ status_t GonkRecorder::dump(
     snprintf(buffer, SIZE, "     Frame rate (fps): %d\n", mFrameRate);
     result.append(buffer);
     snprintf(buffer, SIZE, "     Bit rate (bps): %d\n", mVideoBitRate);
     result.append(buffer);
     ::write(fd, result.string(), result.size());
     return OK;
 }
 
-status_t GonkRecorder::setCameraHandle(int32_t handle) {
-  if (handle < 0) {
-    return BAD_VALUE;
-  }
-  mCameraHandle = handle;
+status_t GonkRecorder::setCamera(const sp<GonkCameraHardware>& aCameraHw) {
+  mCameraHw = aCameraHw;
   return OK;
 }
 
 }  // namespace android
--- a/dom/camera/GonkRecorder.h
+++ b/dom/camera/GonkRecorder.h
@@ -18,27 +18,28 @@
 #ifndef GONK_RECORDER_H_
 #define GONK_RECORDER_H_
 
 #include "nsISupportsImpl.h"
 
 #include <media/mediarecorder.h>
 #include <camera/CameraParameters.h>
 #include <utils/String8.h>
-
 #include <system/audio.h>
+#include "GonkCameraHwMgr.h"
 
 namespace android {
 
 class GonkCameraSource;
 struct MediaSource;
 struct MediaWriter;
 class MetaData;
 struct AudioSource;
 class MediaProfiles;
+class GonkCameraHardware;
 
 struct GonkRecorder {
     NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GonkRecorder)
 
     GonkRecorder();
 
     virtual status_t init();
     virtual status_t setAudioSource(audio_source_t as);
@@ -46,17 +47,17 @@ struct GonkRecorder {
     virtual status_t setOutputFormat(output_format of);
     virtual status_t setAudioEncoder(audio_encoder ae);
     virtual status_t setVideoEncoder(video_encoder ve);
     virtual status_t setVideoSize(int width, int height);
     virtual status_t setVideoFrameRate(int frames_per_second);
     virtual status_t setOutputFile(const char *path);
     virtual status_t setOutputFile(int fd, int64_t offset, int64_t length);
     virtual status_t setParameters(const String8& params);
-    virtual status_t setCameraHandle(int32_t handle);
+    virtual status_t setCamera(const sp<GonkCameraHardware>& aCameraHw);
     virtual status_t setListener(const sp<IMediaRecorderClient>& listener);
     virtual status_t prepare();
     virtual status_t start();
     virtual status_t pause();
     virtual status_t stop();
     virtual status_t close();
     virtual status_t reset();
     virtual status_t getMaxAmplitude(int *max);
@@ -106,17 +107,17 @@ private:
     MediaProfiles *mEncoderProfiles;
 
     bool mStarted;
     // Needed when GLFrames are encoded.
     // An <ISurfaceTexture> pointer
     // will be sent to the client side using which the
     // frame buffers will be queued and dequeued
     bool mDisableAudio;
-    int32_t mCameraHandle;
+    sp<GonkCameraHardware> mCameraHw;
 
     status_t setupMPEG4Recording(
         int outputFd,
         int32_t videoWidth, int32_t videoHeight,
         int32_t videoBitRate,
         int32_t *totalBitRate,
         sp<MediaWriter> *mediaWriter);
     void setupMPEG4MetaData(int64_t startTimeUs, int32_t totalBitRate,