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