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 media {
     13 struct VideoCaptureCapability;
     14 }
     15 
     16 namespace content {
     17 
     18 // ID used for identifying an object of VideoCaptureController.
     19 struct CONTENT_EXPORT VideoCaptureControllerID {
     20   explicit VideoCaptureControllerID(int device_id);
     21 
     22   bool operator<(const VideoCaptureControllerID& vc) const;
     23   bool operator==(const VideoCaptureControllerID& vc) const;
     24 
     25   int device_id;
     26 };
     27 
     28 // VideoCaptureControllerEventHandler is the interface for
     29 // VideoCaptureController to notify clients about the events such as
     30 // BufferReady, FrameInfo, Error, etc.
     31 class CONTENT_EXPORT VideoCaptureControllerEventHandler {
     32  public:
     33   // An Error has occurred in the VideoCaptureDevice.
     34   virtual void OnError(const VideoCaptureControllerID& id) = 0;
     35 
     36   // A buffer has been newly created.
     37   virtual void OnBufferCreated(const VideoCaptureControllerID& id,
     38                                base::SharedMemoryHandle handle,
     39                                int length, int buffer_id) = 0;
     40 
     41   // A buffer has been filled with I420 video.
     42   virtual void OnBufferReady(const VideoCaptureControllerID& id,
     43                              int buffer_id,
     44                              base::Time timestamp) = 0;
     45 
     46   // The frame resolution the VideoCaptureDevice capture video in.
     47   virtual void OnFrameInfo(const VideoCaptureControllerID& id,
     48                            const media::VideoCaptureCapability& format) = 0;
     49 
     50   // The frame resolution the VideoCaptureDevice capture video in.
     51   virtual void OnFrameInfoChanged(const VideoCaptureControllerID& id,
     52                                   int width,
     53                                   int height,
     54                                   int frame_rate) {};
     55 
     56   // The capture session has ended and no more frames will be sent.
     57   virtual void OnEnded(const VideoCaptureControllerID& id) = 0;
     58 
     59  protected:
     60   virtual ~VideoCaptureControllerEventHandler() {}
     61 };
     62 
     63 }  // namespace content
     64 
     65 #endif  // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_CONTROLLER_EVENT_HANDLER_H_
     66