Home | History | Annotate | Download | only in media
      1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_EVENT_HANDLER_H_
      6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_EVENT_HANDLER_H_
      7 
      8 #include "base/memory/shared_memory.h"
      9 #include "base/time/time.h"
     10 #include "content/common/content_export.h"
     11 
     12 namespace gfx {
     13 class Rect;
     14 }  // namespace gfx
     15 
     16 namespace gpu {
     17 struct MailboxHolder;
     18 }  // namespace gpu
     19 
     20 namespace media {
     21 class VideoCaptureFormat;
     22 }  // namespace media
     23 
     24 namespace content {
     25 
     26 // ID used for identifying an object of VideoCaptureController.
     27 struct CONTENT_EXPORT VideoCaptureControllerID {
     28   explicit VideoCaptureControllerID(int device_id);
     29 
     30   bool operator<(const VideoCaptureControllerID& vc) const;
     31   bool operator==(const VideoCaptureControllerID& vc) const;
     32 
     33   int device_id;
     34 };
     35 
     36 // VideoCaptureControllerEventHandler is the interface for
     37 // VideoCaptureController to notify clients about the events such as
     38 // BufferReady, FrameInfo, Error, etc.
     39 class CONTENT_EXPORT VideoCaptureControllerEventHandler {
     40  public:
     41   // An Error has occurred in the VideoCaptureDevice.
     42   virtual void OnError(const VideoCaptureControllerID& id) = 0;
     43 
     44   // A buffer has been newly created.
     45   virtual void OnBufferCreated(const VideoCaptureControllerID& id,
     46                                base::SharedMemoryHandle handle,
     47                                int length,
     48                                int buffer_id) = 0;
     49 
     50   // A previously created buffer has been freed and will no longer be used.
     51   virtual void OnBufferDestroyed(const VideoCaptureControllerID& id,
     52                                  int buffer_id) = 0;
     53 
     54   // A buffer has been filled with I420 video.
     55   virtual void OnBufferReady(const VideoCaptureControllerID& id,
     56                              int buffer_id,
     57                              const media::VideoCaptureFormat& format,
     58                              const gfx::Rect& visible_rect,
     59                              base::TimeTicks timestamp) = 0;
     60 
     61   // A texture mailbox buffer has been filled with data.
     62   virtual void OnMailboxBufferReady(const VideoCaptureControllerID& id,
     63                                     int buffer_id,
     64                                     const gpu::MailboxHolder& mailbox_holder,
     65                                     const media::VideoCaptureFormat& format,
     66                                     base::TimeTicks timestamp) = 0;
     67 
     68   // The capture session has ended and no more frames will be sent.
     69   virtual void OnEnded(const VideoCaptureControllerID& id) = 0;
     70 
     71  protected:
     72   virtual ~VideoCaptureControllerEventHandler() {}
     73 };
     74 
     75 }  // namespace content
     76 
     77 #endif  // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_EVENT_HANDLER_H_
     78