diff options
author | hshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 20:03:42 +0000 |
---|---|---|
committer | hshi@chromium.org <hshi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-02 20:03:42 +0000 |
commit | 76bf7f58d93256dfa5867b6730e446517ead2a30 (patch) | |
tree | 184a18d6d0ed95cfb13303ca6af1fb3b6ed8d44f /media | |
parent | 9c1daf729ceb981ca1650999a15d31d8dc0d1294 (diff) | |
download | chromium_src-76bf7f58d93256dfa5867b6730e446517ead2a30.zip chromium_src-76bf7f58d93256dfa5867b6730e446517ead2a30.tar.gz chromium_src-76bf7f58d93256dfa5867b6730e446517ead2a30.tar.bz2 |
Define EncodedVideoSource and RtcCapturedEncodingVideoCapturer.
Defined the interfaces for EVS (EncodedVideoSource) and related IPC messages
between renderer and browser processes for the purpose of encoded screen capture.
Added RtcCapturedEncodingVideoCapturerFactory which implements the
libjingle::WebRtcVideoEncoderFactory class, and the corresponding
RtcCapturedEncodingVideoCapturer which implements the webrtc::VideoEncoder.
Modify MediaStreamDependencyFactory and inject RtcCapturedEncodingVideoCaptureFactory
in PeerConnectionFactory. For the time being, the factory will only be instantiated
for Chrome OS and ARM.
BUG=238515
TEST=trybot
Review URL: https://chromiumcodereview.appspot.com/16320005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209760 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r-- | media/base/encoded_bitstream_buffer.cc | 50 | ||||
-rw-r--r-- | media/base/encoded_bitstream_buffer.h | 52 | ||||
-rw-r--r-- | media/media.gyp | 4 | ||||
-rw-r--r-- | media/video/encoded_video_source.h | 76 | ||||
-rw-r--r-- | media/video/video_encode_types.h | 51 |
5 files changed, 233 insertions, 0 deletions
diff --git a/media/base/encoded_bitstream_buffer.cc b/media/base/encoded_bitstream_buffer.cc new file mode 100644 index 0000000..3689015 --- /dev/null +++ b/media/base/encoded_bitstream_buffer.cc @@ -0,0 +1,50 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "media/base/encoded_bitstream_buffer.h" + +#include "base/logging.h" + +namespace media { + +EncodedBitstreamBuffer::EncodedBitstreamBuffer( + int buffer_id, + uint8* buffer, + uint32 size, + base::SharedMemoryHandle handle, + const media::BufferEncodingMetadata& metadata, + const base::Closure& destroy_cb) + : buffer_id_(buffer_id), + buffer_(buffer), + size_(size), + shared_memory_handle_(handle), + metadata_(metadata), + destroy_cb_(destroy_cb) { +} + +EncodedBitstreamBuffer::~EncodedBitstreamBuffer() { + destroy_cb_.Run(); +} + +int EncodedBitstreamBuffer::buffer_id() const { + return buffer_id_; +} + +const uint8* EncodedBitstreamBuffer::buffer() const { + return buffer_; +} + +uint32 EncodedBitstreamBuffer::size() const { + return size_; +} + +base::SharedMemoryHandle EncodedBitstreamBuffer::shared_memory_handle() const { + return shared_memory_handle_; +} + +const media::BufferEncodingMetadata& EncodedBitstreamBuffer::metadata() const { + return metadata_; +} + +} // namespace media diff --git a/media/base/encoded_bitstream_buffer.h b/media/base/encoded_bitstream_buffer.h new file mode 100644 index 0000000..6fe24c8 --- /dev/null +++ b/media/base/encoded_bitstream_buffer.h @@ -0,0 +1,52 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_BASE_ENCODED_BITSTREAM_BUFFER_H_ +#define MEDIA_BASE_ENCODED_BITSTREAM_BUFFER_H_ + +#include "base/callback_forward.h" +#include "base/memory/ref_counted.h" +#include "base/shared_memory.h" +#include "base/time/time.h" +#include "media/base/media_export.h" +#include "media/video/video_encode_types.h" + +namespace media { + +// General encoded video bitstream buffer. +class MEDIA_EXPORT EncodedBitstreamBuffer : + public base::RefCountedThreadSafe<EncodedBitstreamBuffer> { + public: + EncodedBitstreamBuffer(int buffer_id, + uint8* buffer, + uint32 size, + base::SharedMemoryHandle handle, + const media::BufferEncodingMetadata& metadata, + const base::Closure& destroy_cb); + // Accessors for properties. + int buffer_id() const; + const uint8* buffer() const; + uint32 size() const; + base::SharedMemoryHandle shared_memory_handle() const; + const media::BufferEncodingMetadata& metadata() const; + + protected: + // Destructor that deallocates the buffers. + virtual ~EncodedBitstreamBuffer(); + friend class base::RefCountedThreadSafe<EncodedBitstreamBuffer>; + + private: + int buffer_id_; + uint8* buffer_; + uint32 size_; + const base::SharedMemoryHandle shared_memory_handle_; + media::BufferEncodingMetadata metadata_; + const base::Closure destroy_cb_; + + DISALLOW_COPY_AND_ASSIGN(EncodedBitstreamBuffer); +}; + +} // namespace media + +#endif // MEDIA_BASE_ENCODED_BITSTREAM_BUFFER_H_ diff --git a/media/media.gyp b/media/media.gyp index 10ee0f8..88b28dc 100644 --- a/media/media.gyp +++ b/media/media.gyp @@ -258,6 +258,8 @@ 'base/demuxer_stream.h', 'base/djb2.cc', 'base/djb2.h', + 'base/encoded_bitstream_buffer.cc', + 'base/encoded_bitstream_buffer.h', 'base/filter_collection.cc', 'base/filter_collection.h', 'base/media.cc', @@ -413,10 +415,12 @@ 'video/capture/win/video_capture_device_mf_win.h', 'video/capture/win/video_capture_device_win.cc', 'video/capture/win/video_capture_device_win.h', + 'video/encoded_video_source.h', 'video/picture.cc', 'video/picture.h', 'video/video_decode_accelerator.cc', 'video/video_decode_accelerator.h', + 'video/video_encode_types.h', 'webm/webm_audio_client.cc', 'webm/webm_audio_client.h', 'webm/webm_cluster_parser.cc', diff --git a/media/video/encoded_video_source.h b/media/video/encoded_video_source.h new file mode 100644 index 0000000..e2ce201 --- /dev/null +++ b/media/video/encoded_video_source.h @@ -0,0 +1,76 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_ +#define MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_ + +#include "base/memory/ref_counted.h" +#include "media/base/encoded_bitstream_buffer.h" +#include "media/video/video_encode_types.h" + +namespace media { + +// Class to represent any encoded video source. Anything that provides encoded +// video can be an EncodedVideoSource. Notable examples of this can be video +// encoder and webcam that has encoding capabilities. +// TODO(hshi): merge this with VEA interface. http://crbug.com/248334. +class EncodedVideoSource { + public: + class Client { + public: + // Notifies client that bitstream is opened successfully. The |params| + // contains the actual encoding parameters chosen by the browser process. + // It may be different from the params requested in OpenBitstream(). + virtual void OnOpened(const VideoEncodingParameters& params) = 0; + + // Notifies client that bitstream is closed. After this call it is + // guaranteed that client will not receive further calls. + virtual void OnClosed() = 0; + + // Delivers an encoded bitstream buffer to the client. + virtual void OnBufferReady( + scoped_refptr<const EncodedBitstreamBuffer> buffer) = 0; + + // Notifies client that encoding parameters has changed. The |params| + // contains the current encoding parameters chosen by the browser process. + // It may be different from the params requested in TrySetBitstreamConfig(). + virtual void OnConfigChanged( + const RuntimeVideoEncodingParameters& params) = 0; + }; + + // Callback is invoked once RequestCapabilities() is complete. + typedef base::Callback<void(const VideoEncodingCapabilities& capabilities)> + RequestCapabilitiesCallback; + + // RequestCapabilities initiates an asynchronous query for the types of + // encoded bitstream supported by the encoder. This call should be invoked + // only once. EncodedVideoSource will invoke |callback| when capabilities + // become available. + virtual void RequestCapabilities( + const RequestCapabilitiesCallback& callback) = 0; + + // OpenBitstream opens the bitstream on the encoded video source. Only one + // bitstream can be opened for an encoded video source. + virtual void OpenBitstream(Client* client, + const VideoEncodingParameters& params) = 0; + + // CloseBitstream closes the bitstream. + virtual void CloseBitstream() = 0; + + // ReturnBitstreamBuffer notifies that the data within the buffer has been + // processed and it can be reused to encode upcoming bitstream. + virtual void ReturnBitstreamBuffer( + scoped_refptr<const media::EncodedBitstreamBuffer> buffer) = 0; + + // TrySetBitstreamConfig requests to change encoding parameters. Old config + // must be considered valid until OnConfigChanged is invoked on the client + // signaling successful change. + virtual void TrySetBitstreamConfig( + const RuntimeVideoEncodingParameters& params) = 0; +}; + +} // namespace media + +#endif // MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_ + diff --git a/media/video/video_encode_types.h b/media/video/video_encode_types.h new file mode 100644 index 0000000..0372019 --- /dev/null +++ b/media/video/video_encode_types.h @@ -0,0 +1,51 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +#ifndef MEDIA_VIDEO_VIDEO_ENCODE_TYPES_H_ +#define MEDIA_VIDEO_VIDEO_ENCODE_TYPES_H_ + +#include <map> +#include <ostream> +#include <vector> + +#include "base/time/time.h" +#include "media/base/video_decoder_config.h" +#include "ui/gfx/size.h" + +namespace media { + +// Data to represent limitations for a particular encoder config. +struct VideoEncodingConfig { + VideoCodec codec_type; + std::string codec_name; + gfx::Size max_resolution; + int max_frames_per_second; + int max_bitrate; +}; + +typedef std::vector<VideoEncodingConfig> VideoEncodingCapabilities; + +// Encoding parameters that can be configured during streaming without removing +// the bitstream first. +struct RuntimeVideoEncodingParameters { + int target_bitrate; + int max_bitrate; + int frames_per_second; +}; + +// Generic video encoding parameters to be configured during initialization +// time. +struct VideoEncodingParameters { + std::string codec_name; + gfx::Size resolution; + RuntimeVideoEncodingParameters runtime_params; +}; + +struct BufferEncodingMetadata { + base::Time timestamp; + bool key_frame; +}; + +} // namespace media + +#endif // MEDIA_VIDEO_VIDEO_ENCODE_TYPES_H_ |