Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "media/base/bitstream_buffer.h" | 15 #include "media/base/bitstream_buffer.h" |
| 16 #include "media/base/cdm_context.h" | |
| 16 #include "media/base/surface_manager.h" | 17 #include "media/base/surface_manager.h" |
| 17 #include "media/base/video_decoder_config.h" | 18 #include "media/base/video_decoder_config.h" |
| 18 #include "media/video/picture.h" | 19 #include "media/video/picture.h" |
| 19 #include "ui/gfx/geometry/size.h" | 20 #include "ui/gfx/geometry/size.h" |
| 20 #include "ui/gfx/gpu_memory_buffer.h" | 21 #include "ui/gfx/gpu_memory_buffer.h" |
| 21 | 22 |
| 22 typedef unsigned int GLenum; | 23 typedef unsigned int GLenum; |
| 23 | 24 |
| 24 namespace base { | 25 namespace base { |
| 25 class SingleThreadTaskRunner; | 26 class SingleThreadTaskRunner; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 // for PictureBuffers at the time of AssignPictureBuffers() call. | 109 // for PictureBuffers at the time of AssignPictureBuffers() call. |
| 109 // When set to IMPORT, the VDA will not allocate, but after receiving | 110 // When set to IMPORT, the VDA will not allocate, but after receiving |
| 110 // AssignPictureBuffers() call, it will expect a call to | 111 // AssignPictureBuffers() call, it will expect a call to |
| 111 // ImportBufferForPicture() for each PictureBuffer before use. | 112 // ImportBufferForPicture() for each PictureBuffer before use. |
| 112 enum class OutputMode { | 113 enum class OutputMode { |
| 113 ALLOCATE, | 114 ALLOCATE, |
| 114 IMPORT, | 115 IMPORT, |
| 115 }; | 116 }; |
| 116 | 117 |
| 117 Config() = default; | 118 Config() = default; |
| 119 // Intentional converting constructor. | |
|
sandersd (OOO until July 31)
2016/05/10 00:09:54
Newline before comment. Add a TODO.
| |
| 118 Config(VideoCodecProfile profile); | 120 Config(VideoCodecProfile profile); |
| 119 Config(const VideoDecoderConfig& video_decoder_config); | |
|
watk
2016/05/09 23:39:59
I removed this because it felt clearer to initiali
| |
| 120 | 121 |
| 121 std::string AsHumanReadableString() const; | 122 std::string AsHumanReadableString() const; |
| 122 | 123 |
| 123 // |profile| combines the information about the codec and its profile. | 124 // The video codec and profile. |
| 124 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; | 125 VideoCodecProfile profile = VIDEO_CODEC_PROFILE_UNKNOWN; |
| 125 | 126 |
| 126 // The flag indicating whether the stream is encrypted. | 127 // Whether the stream is encrypted. |
| 127 bool is_encrypted = false; | 128 bool is_encrypted = false; |
| 128 | 129 |
| 129 // The flag indicating whether the client supports deferred initialization | 130 // The CDM that the VDA should use to decode encrypted streams. Must be |
| 130 // or not. | 131 // set to a valid ID if |is_encrypted|. |
| 132 int cdm_id = CdmContext::kInvalidCdmId; | |
| 133 | |
| 134 // Whether the client supports deferred initialization. | |
| 131 bool is_deferred_initialization_allowed = false; | 135 bool is_deferred_initialization_allowed = false; |
| 132 | 136 |
| 133 // An optional graphics surface that the VDA should render to. For setting | 137 // An optional graphics surface that the VDA should render to. For setting |
| 134 // an output SurfaceView on Android. It's only valid when not equal to | 138 // an output SurfaceView on Android. It's only valid when not equal to |
| 135 // |kNoSurfaceID|. | 139 // |kNoSurfaceID|. |
| 136 int surface_id = kNoSurfaceID; | 140 int surface_id = kNoSurfaceID; |
| 137 | 141 |
| 138 // Coded size of the video frame hint, subject to change. | 142 // Coded size of the video frame hint, subject to change. |
| 139 gfx::Size initial_expected_coded_size = gfx::Size(320, 240); | 143 gfx::Size initial_expected_coded_size = gfx::Size(320, 240); |
| 140 | 144 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 // decoder construction. This call is synchronous and returns true iff | 201 // decoder construction. This call is synchronous and returns true iff |
| 198 // initialization is successful, unless deferred initialization is used. | 202 // initialization is successful, unless deferred initialization is used. |
| 199 // | 203 // |
| 200 // By default, deferred initialization is not used. However, if Config:: | 204 // By default, deferred initialization is not used. However, if Config:: |
| 201 // is_deferred_initialization_allowed is set by the client, and if | 205 // is_deferred_initialization_allowed is set by the client, and if |
| 202 // Capabilities::Flags::SUPPORTS_DEFERRED_INITIALIZATION is set by the VDA, | 206 // Capabilities::Flags::SUPPORTS_DEFERRED_INITIALIZATION is set by the VDA, |
| 203 // and if VDA::Initialize returns true, then the client can expect a call to | 207 // and if VDA::Initialize returns true, then the client can expect a call to |
| 204 // NotifyInitializationComplete with the actual success / failure of | 208 // NotifyInitializationComplete with the actual success / failure of |
| 205 // initialization. Note that a return value of false from VDA::Initialize | 209 // initialization. Note that a return value of false from VDA::Initialize |
| 206 // indicates that initialization definitely failed, and no callback is needed. | 210 // indicates that initialization definitely failed, and no callback is needed. |
| 207 // TODO(liberato): should we say that encrypted video requires deferred? | |
| 208 // | 211 // |
| 209 // For encrpyted video, the decoder needs a CDM to be able to decode encrypted | 212 // For encrypted video, only deferred initialization is supported and |config| |
| 210 // buffers. SetCdm() should be called after Initialize() to set such a CDM. | 213 // must contain a valid |cdm_id|. |
| 211 // Client::NotifyCdmAttached() will then be called to indicate whether the CDM | |
| 212 // is successfully attached to the decoder. Only when a CDM is successfully | |
| 213 // attached can we start to decode. | |
| 214 // | 214 // |
| 215 // Parameters: | 215 // Parameters: |
| 216 // |config| contains the initialization parameters. | 216 // |config| contains the initialization parameters. |
| 217 // |client| is the client of this video decoder. Does not take ownership of | 217 // |client| is the client of this video decoder. Does not take ownership of |
| 218 // |client| which must be valid until Destroy() is called. | 218 // |client| which must be valid until Destroy() is called. |
| 219 virtual bool Initialize(const Config& config, Client* client) = 0; | 219 virtual bool Initialize(const Config& config, Client* client) = 0; |
| 220 | 220 |
| 221 // Sets a CDM to be used by the decoder to decode encrypted buffers. | |
| 222 // Client::NotifyCdmAttached() will then be called to indicate whether the CDM | |
| 223 // is successfully attached to the decoder. The default implementation is a | |
| 224 // no-op since most VDAs don't support encrypted video. | |
| 225 virtual void SetCdm(int cdm_id); | |
| 226 | |
| 227 // Decodes given bitstream buffer that contains at most one frame. Once | 221 // Decodes given bitstream buffer that contains at most one frame. Once |
| 228 // decoder is done with processing |bitstream_buffer| it will call | 222 // decoder is done with processing |bitstream_buffer| it will call |
| 229 // NotifyEndOfBitstreamBuffer() with the bitstream buffer id. | 223 // NotifyEndOfBitstreamBuffer() with the bitstream buffer id. |
| 230 // Parameters: | 224 // Parameters: |
| 231 // |bitstream_buffer| is the input bitstream that is sent for decoding. | 225 // |bitstream_buffer| is the input bitstream that is sent for decoding. |
| 232 virtual void Decode(const BitstreamBuffer& bitstream_buffer) = 0; | 226 virtual void Decode(const BitstreamBuffer& bitstream_buffer) = 0; |
| 233 | 227 |
| 234 // Assigns a set of texture-backed picture buffers to the video decoder. | 228 // Assigns a set of texture-backed picture buffers to the video decoder. |
| 235 // | 229 // |
| 236 // Ownership of each picture buffer remains with the client, but the client | 230 // Ownership of each picture buffer remains with the client, but the client |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 // std::unique_ptr<VideoDecodeAccelerator> uses "Destroy()" instead of trying to | 333 // std::unique_ptr<VideoDecodeAccelerator> uses "Destroy()" instead of trying to |
| 340 // use the destructor. | 334 // use the destructor. |
| 341 template <> | 335 template <> |
| 342 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> { | 336 struct MEDIA_EXPORT default_delete<media::VideoDecodeAccelerator> { |
| 343 void operator()(media::VideoDecodeAccelerator* vda) const; | 337 void operator()(media::VideoDecodeAccelerator* vda) const; |
| 344 }; | 338 }; |
| 345 | 339 |
| 346 } // namespace std | 340 } // namespace std |
| 347 | 341 |
| 348 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ | 342 #endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |