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