From c5117655847f3fae8bf1057d2eb9eb199b24c8bb Mon Sep 17 00:00:00 2001 From: Sotaro Ikeda Date: Thu, 24 Jan 2013 21:45:36 -0500 Subject: [PATCH] Bug 833521 - forward "recording-device-events" event to parent process, r=dougt --- dom/camera/DOMCameraControl.cpp | 13 +++++++++++++ dom/ipc/ContentParent.cpp | 12 ++++++++++++ dom/ipc/ContentParent.h | 2 ++ dom/ipc/PContent.ipdl | 2 ++ dom/media/Makefile.in | 1 + dom/media/MediaManager.cpp | 4 ++++ dom/media/MediaManager.h | 13 +++++++++++++ dom/media/nsIDOMMediaStream.idl | 9 ++++++++- 8 files changed, 55 insertions(+), 1 deletion(-) diff --git a/dom/camera/DOMCameraControl.cpp b/dom/camera/DOMCameraControl.cpp index 6a7aa64d3d5..77ef5e48862 100644 --- a/dom/camera/DOMCameraControl.cpp +++ b/dom/camera/DOMCameraControl.cpp @@ -7,9 +7,12 @@ #include "nsDOMClassInfo.h" #include "jsapi.h" #include "nsThread.h" +#include "mozilla/dom/ContentChild.h" #include "mozilla/Services.h" +#include "mozilla/unused.h" #include "nsIObserverService.h" #include "nsIDOMDeviceStorage.h" +#include "nsXULAppAPI.h" #include "DOMCameraManager.h" #include "DOMCameraCapabilities.h" #include "DOMCameraControl.h" @@ -259,6 +262,11 @@ nsDOMCameraControl::StartRecording(const JS::Value& aOptions, nsIDOMDeviceStorag 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) { @@ -291,6 +299,11 @@ nsDOMCameraControl::StopRecording() obs->NotifyObservers(nullptr, "recording-device-events", NS_LITERAL_STRING("shutdown").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("shutdown")); + } #ifdef MOZ_B2G if (mAudioChannelAgent) { diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index f196338d727..d4a1512aee1 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -1230,6 +1230,18 @@ ContentParent::RecvBroadcastVolume(const nsString& aVolumeName) #endif } +bool +ContentParent::RecvRecordingDeviceEvents(const nsString& aRecordingStatus) +{ + nsCOMPtr obs = mozilla::services::GetObserverService(); + if (obs) { + obs->NotifyObservers(nullptr, "recording-device-events", aRecordingStatus.get()); + } else { + NS_WARNING("Could not get the Observer service for ContentParent::RecvRecordingDeviceEvents."); + } + return true; +} + NS_IMPL_THREADSAFE_ISUPPORTS3(ContentParent, nsIObserver, nsIThreadObserver, diff --git a/dom/ipc/ContentParent.h b/dom/ipc/ContentParent.h index b8ae8bef001..88ffda696ac 100644 --- a/dom/ipc/ContentParent.h +++ b/dom/ipc/ContentParent.h @@ -344,6 +344,8 @@ private: virtual bool RecvBroadcastVolume(const nsString& aVolumeName); + virtual bool RecvRecordingDeviceEvents(const nsString& aRecordingStatus); + virtual void ProcessingError(Result what) MOZ_OVERRIDE; GeckoChildProcessHost* mSubprocess; diff --git a/dom/ipc/PContent.ipdl b/dom/ipc/PContent.ipdl index 5d64c3d9393..2b6c58123fd 100644 --- a/dom/ipc/PContent.ipdl +++ b/dom/ipc/PContent.ipdl @@ -437,6 +437,8 @@ parent: // get nsIVolumeService to broadcast volume information async BroadcastVolume(nsString volumeName); + async RecordingDeviceEvents(nsString recordingStatus); + both: AsyncMessage(nsString aMessage, ClonedMessageData aData); }; diff --git a/dom/media/Makefile.in b/dom/media/Makefile.in index 3d16220c61b..0a8f2e928ec 100644 --- a/dom/media/Makefile.in +++ b/dom/media/Makefile.in @@ -56,4 +56,5 @@ TEST_DIRS += \ $(NULL) include $(topsrcdir)/config/config.mk +include $(topsrcdir)/ipc/chromium/chromium-config.mk include $(topsrcdir)/config/rules.mk diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 6a56ace3874..97a6c1eeed0 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -29,6 +29,10 @@ namespace mozilla { +#ifdef LOG +#undef LOG +#endif + #ifdef PR_LOGGING PRLogModuleInfo* GetMediaManagerLog() diff --git a/dom/media/MediaManager.h b/dom/media/MediaManager.h index d026d0d341a..fc1263d8a25 100644 --- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -3,7 +3,9 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "MediaEngine.h" +#include "mozilla/dom/ContentChild.h" #include "mozilla/Services.h" +#include "mozilla/unused.h" #include "nsIMediaManager.h" #include "nsHashKeys.h" @@ -14,6 +16,7 @@ #include "nsPIDOMWindow.h" #include "nsIDOMNavigatorUserMedia.h" +#include "nsXULAppAPI.h" #include "mozilla/Attributes.h" #include "mozilla/StaticPtr.h" #include "prlog.h" @@ -49,10 +52,20 @@ class GetUserMediaNotificationEvent: public nsRunnable 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 << mozilla::dom::ContentChild::GetSingleton()->SendRecordingDeviceEvents(NS_LITERAL_STRING("starting")); + } } else { obs->NotifyObservers(nullptr, "recording-device-events", NS_LITERAL_STRING("shutdown").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 << mozilla::dom::ContentChild::GetSingleton()->SendRecordingDeviceEvents(NS_LITERAL_STRING("shutdown")); + } } return NS_OK; } diff --git a/dom/media/nsIDOMMediaStream.idl b/dom/media/nsIDOMMediaStream.idl index 9e84b9f810a..b788f70f7bb 100644 --- a/dom/media/nsIDOMMediaStream.idl +++ b/dom/media/nsIDOMMediaStream.idl @@ -4,7 +4,14 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsISupports.idl" - + +// undef the GetCurrentTime macro defined in WinBase.h from the MS Platform SDK +%{C++ +#ifdef GetCurrentTime +#undef GetCurrentTime +#endif +%} + [scriptable, builtinclass, uuid(f37c2871-4cb7-4672-bb28-c2d601f7cc9e)] interface nsIDOMMediaStream : nsISupports {