/* [implicit_jscontext] void startRecording (in jsval aOptions, in nsIDOMDeviceStorage storageArea, in DOMString filename, in nsICameraStartRecordingCallback onSuccess, [optional] in nsICameraErrorCallback onError); */ NS_IMETHODIMP nsDOMCameraControl::StartRecording(const JS::Value& aOptions, nsIDOMDeviceStorage* storageArea, const nsAString& filename, nsICameraStartRecordingCallback* onSuccess, nsICameraErrorCallback* onError, JSContext* cx) { NS_ENSURE_TRUE(onSuccess, NS_ERROR_INVALID_ARG); NS_ENSURE_TRUE(storageArea, NS_ERROR_INVALID_ARG); CameraStartRecordingOptions options; // Default values, until the dictionary parser can handle them. options.rotation = 0; options.maxFileSizeBytes = 0; options.maxVideoLengthMs = 0; nsresult rv = options.Init(cx, &aOptions); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); if (!obs) { NS_WARNING("Could not get the Observer service for CameraControl::StartRecording."); return NS_ERROR_FAILURE; } obs->NotifyObservers(nullptr, "recording-device-events", NS_LITERAL_STRING("starting").get()); nsCOMPtr<nsIFile> folder; storageArea->GetRootDirectory(getter_AddRefs(folder)); return mCameraControl->StartRecording(&options, folder, filename, onSuccess, onError); }
/* [implicit_jscontext] void startRecording (in jsval aOptions, in nsIDOMDeviceStorage storageArea, in DOMString filename, in nsICameraStartRecordingCallback onSuccess, [optional] in nsICameraErrorCallback onError); */ NS_IMETHODIMP nsDOMCameraControl::StartRecording(const JS::Value& aOptions, nsIDOMDeviceStorage* storageArea, const nsAString& filename, nsICameraStartRecordingCallback* onSuccess, nsICameraErrorCallback* onError, JSContext* cx) { NS_ENSURE_TRUE(onSuccess, NS_ERROR_INVALID_ARG); NS_ENSURE_TRUE(storageArea, NS_ERROR_INVALID_ARG); CameraStartRecordingOptions options; // Default values, until the dictionary parser can handle them. options.rotation = 0; options.maxFileSizeBytes = 0; options.maxVideoLengthMs = 0; nsresult rv = options.Init(cx, &aOptions); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService(); if (!obs) { NS_WARNING("Could not get the Observer service for CameraControl::StartRecording."); return NS_ERROR_FAILURE; } obs->NotifyObservers(nullptr, "recording-device-events", NS_LITERAL_STRING("starting").get()); // Forward recording events to parent process. // The events are gathered in chrome process and used for recording indicator if (XRE_GetProcessType() != GeckoProcessType_Default) { unused << ContentChild::GetSingleton()->SendRecordingDeviceEvents(NS_LITERAL_STRING("starting")); } #ifdef MOZ_B2G if (!mAudioChannelAgent) { mAudioChannelAgent = do_CreateInstance("@mozilla.org/audiochannelagent;1"); if (mAudioChannelAgent) { // Camera app will stop recording when it falls to the background, so no callback is necessary. mAudioChannelAgent->Init(AUDIO_CHANNEL_CONTENT, nullptr); // Video recording doesn't output any sound, so it's not necessary to check canPlay. bool canPlay; mAudioChannelAgent->StartPlaying(&canPlay); } } #endif nsCOMPtr<nsIFile> folder; storageArea->GetRootDirectory(getter_AddRefs(folder)); return mCameraControl->StartRecording(&options, folder, filename, onSuccess, onError); }