Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: content/renderer/pepper/pepper_platform_video_capture.h

Issue 242013002: Refactor video capturing code in the render process (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged again :( Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/pepper/pepper_platform_video_capture.h
diff --git a/content/renderer/pepper/pepper_platform_video_capture.h b/content/renderer/pepper/pepper_platform_video_capture.h
index 1d0b47c68ae554ad73c552358af0aa57938f77b5..c3a1c3d15fe869d2242d66f356f6b11502715860 100644
--- a/content/renderer/pepper/pepper_platform_video_capture.h
+++ b/content/renderer/pepper/pepper_platform_video_capture.h
@@ -8,66 +8,43 @@
#include <string>
#include "base/basictypes.h"
+#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
-#include "media/video/capture/video_capture.h"
+#include "content/common/media/video_capture.h"
#include "media/video/capture/video_capture_types.h"
class GURL;
-namespace media {
-class VideoCaptureHandlerProxy;
-}
-
namespace content {
class PepperMediaDeviceManager;
class PepperVideoCaptureHost;
class RenderViewImpl;
-class VideoCaptureHandle;
-class PepperPlatformVideoCapture
- : public media::VideoCapture,
- public base::RefCounted<PepperPlatformVideoCapture>,
- public media::VideoCapture::EventHandler {
+// This is an render thread only object. All methods must be accessed on
Ami GONE FROM CHROMIUM 2014/04/24 21:04:31 s/an/a/
Alpha Left Google 2014/04/24 22:50:34 Done.
+// the render thread including cosntructor and destructor.
Ami GONE FROM CHROMIUM 2014/04/24 21:04:31 optional: could DCHECK this in the public methods.
Alpha Left Google 2014/04/24 22:50:34 Done.
+class PepperPlatformVideoCapture {
public:
PepperPlatformVideoCapture(const base::WeakPtr<RenderViewImpl>& render_view,
const std::string& device_id,
const GURL& document_url,
PepperVideoCaptureHost* handler);
+ virtual ~PepperPlatformVideoCapture();
// Detaches the event handler and stops sending notifications to it.
void DetachEventHandler();
- // media::VideoCapture implementation.
- virtual void StartCapture(media::VideoCapture::EventHandler* handler,
- const media::VideoCaptureParams& params) OVERRIDE;
- virtual void StopCapture(media::VideoCapture::EventHandler* handler) OVERRIDE;
- virtual bool CaptureStarted() OVERRIDE;
- virtual int CaptureFrameRate() OVERRIDE;
- virtual void GetDeviceSupportedFormats(const DeviceFormatsCallback& callback)
- OVERRIDE;
- virtual void GetDeviceFormatsInUse(const DeviceFormatsInUseCallback& callback)
- OVERRIDE;
-
- // media::VideoCapture::EventHandler implementation
- virtual void OnStarted(VideoCapture* capture) OVERRIDE;
- virtual void OnStopped(VideoCapture* capture) OVERRIDE;
- virtual void OnPaused(VideoCapture* capture) OVERRIDE;
- virtual void OnError(VideoCapture* capture, int error_code) OVERRIDE;
- virtual void OnRemoved(VideoCapture* capture) OVERRIDE;
- virtual void OnFrameReady(VideoCapture* capture,
- const scoped_refptr<media::VideoFrame>& frame)
- OVERRIDE;
-
- protected:
- friend class base::RefCounted<PepperPlatformVideoCapture>;
- virtual ~PepperPlatformVideoCapture();
+ void StartCapture(const media::VideoCaptureParams& params);
+ void StopCapture();
private:
- void Initialize();
-
void OnDeviceOpened(int request_id, bool succeeded, const std::string& label);
+ void OnStateUpdate(VideoCaptureState state);
+ void OnFrameReady(
+ const scoped_refptr<media::VideoFrame>& frame,
+ const media::VideoCaptureFormat& format,
+ const base::TimeTicks& timestamp);
PepperMediaDeviceManager* GetMediaDeviceManager();
@@ -76,22 +53,18 @@ class PepperPlatformVideoCapture
std::string device_id_;
std::string label_;
int session_id_;
-
- scoped_ptr<media::VideoCaptureHandlerProxy> handler_proxy_;
+ base::Closure release_device_cb_;
+ base::Closure stop_capture_cb_;
PepperVideoCaptureHost* handler_;
- scoped_ptr<VideoCaptureHandle> video_capture_;
-
- // StartCapture() must be balanced by StopCapture(), otherwise this object
- // will leak.
- bool unbalanced_start_;
-
// Whether we have a pending request to open a device. We have to make sure
// there isn't any pending request before this object goes away.
bool pending_open_device_;
int pending_open_device_id_;
+ base::WeakPtrFactory<PepperPlatformVideoCapture> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(PepperPlatformVideoCapture);
};

Powered by Google App Engine
This is Rietveld 408576698