Commit 22094b8b authored by Miguel Casas's avatar Miguel Casas Committed by Commit Bot

media/gpu: add default-null argument to SetStream() ISO SetEncryptedStream()

This CL follows up on a comment [1] on the CL landing SetEncryptedStream(),
("We could do SetStream(..., const DecryptConfig* decrypt_config) as nullptr
is used in other places to indicate that there is no decrypt config."), by
removing SetEncryptedStream() and adding instead a default-null argument
|decrypt_config| SetStream instead(). SetStream and SetEncryptedStream
are so similar from an APi perspective that it doesn't seem to merit a
method on its own.

Note: SetStream() is fully synchronous and DecrypConfig is a plain vanilla
class, so nacked pointer is good enough (we could also consider
std::unique_ptr<> instead, down the line).


[1] https://chromium-review.googlesource.com/c/chromium/src/+/1024961/8/media/gpu/accelerated_video_decoder.h#35

Bug: 820192
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Iec056f33a792965f8bf854d9564e3bff520f4f8d
Reviewed-on: https://chromium-review.googlesource.com/1061621Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560778}
parent 41f5f31a
...@@ -26,16 +26,13 @@ class MEDIA_GPU_EXPORT AcceleratedVideoDecoder { ...@@ -26,16 +26,13 @@ class MEDIA_GPU_EXPORT AcceleratedVideoDecoder {
// Set the buffer at |ptr| of |size| bytes as the current source of encoded // Set the buffer at |ptr| of |size| bytes as the current source of encoded
// stream data. Pictures produced as a result of this call should be assigned // stream data. Pictures produced as a result of this call should be assigned
// the passed stream |id|. // the passed stream |id|. |decrypt_config| may specify the decryption
virtual void SetStream(int32_t id, const uint8_t* ptr, size_t size) = 0; // configuration of the specified buffer, and in that case, Decode() may
// return kNoKey.
// This is the same as SetStream() but is for setting an encrypted buffer. virtual void SetStream(int32_t id,
// |decrypt_config| specifies the decryption configuration of the specified const uint8_t* ptr,
// buffer. If the stream is set with this method, Decode() may return kNoKey. size_t size,
virtual void SetEncryptedStream(int32_t id, const DecryptConfig* decrypt_config = nullptr) = 0;
const uint8_t* ptr,
size_t size,
const DecryptConfig& decrypt_config) = 0;
// Have the decoder flush its state and trigger output of all previously // Have the decoder flush its state and trigger output of all previously
// decoded surfaces. Return false on failure. // decoded surfaces. Return false on failure.
......
...@@ -1224,9 +1224,17 @@ bool H264Decoder::ProcessCurrentSlice() { ...@@ -1224,9 +1224,17 @@ bool H264Decoder::ProcessCurrentSlice() {
return H264Decoder::kDecodeError; \ return H264Decoder::kDecodeError; \
} while (0) } while (0)
void H264Decoder::SetStream(int32_t id, const uint8_t* ptr, size_t size) { void H264Decoder::SetStream(int32_t id,
const uint8_t* ptr,
size_t size,
const DecryptConfig* decrypt_config) {
DCHECK(ptr); DCHECK(ptr);
DCHECK(size); DCHECK(size);
if (decrypt_config) {
NOTIMPLEMENTED();
state_ = kError;
return;
}
DVLOG(4) << "New input stream id: " << id << " at: " << (void*)ptr DVLOG(4) << "New input stream id: " << id << " at: " << (void*)ptr
<< " size: " << size; << " size: " << size;
...@@ -1234,14 +1242,6 @@ void H264Decoder::SetStream(int32_t id, const uint8_t* ptr, size_t size) { ...@@ -1234,14 +1242,6 @@ void H264Decoder::SetStream(int32_t id, const uint8_t* ptr, size_t size) {
parser_.SetStream(ptr, size); parser_.SetStream(ptr, size);
} }
void H264Decoder::SetEncryptedStream(int32_t id,
const uint8_t* ptr,
size_t size,
const DecryptConfig& decrypt_config) {
state_ = kError;
NOTIMPLEMENTED();
}
H264Decoder::DecodeResult H264Decoder::Decode() { H264Decoder::DecodeResult H264Decoder::Decode() {
if (state_ == kError) { if (state_ == kError) {
DVLOG(1) << "Decoder in error state"; DVLOG(1) << "Decoder in error state";
......
...@@ -105,11 +105,10 @@ class MEDIA_GPU_EXPORT H264Decoder : public AcceleratedVideoDecoder { ...@@ -105,11 +105,10 @@ class MEDIA_GPU_EXPORT H264Decoder : public AcceleratedVideoDecoder {
~H264Decoder() override; ~H264Decoder() override;
// AcceleratedVideoDecoder implementation. // AcceleratedVideoDecoder implementation.
void SetStream(int32_t id, const uint8_t* ptr, size_t size) override; void SetStream(int32_t id,
void SetEncryptedStream(int32_t id, const uint8_t* ptr,
const uint8_t* ptr, size_t size,
size_t size, const DecryptConfig* decrypt_config = nullptr) override;
const DecryptConfig& decrypt_config) override;
bool Flush() override WARN_UNUSED_RESULT; bool Flush() override WARN_UNUSED_RESULT;
void Reset() override; void Reset() override;
DecodeResult Decode() override WARN_UNUSED_RESULT; DecodeResult Decode() override WARN_UNUSED_RESULT;
......
...@@ -50,12 +50,9 @@ class MockAcceleratedVideoDecoder : public AcceleratedVideoDecoder { ...@@ -50,12 +50,9 @@ class MockAcceleratedVideoDecoder : public AcceleratedVideoDecoder {
MockAcceleratedVideoDecoder() = default; MockAcceleratedVideoDecoder() = default;
~MockAcceleratedVideoDecoder() override = default; ~MockAcceleratedVideoDecoder() override = default;
MOCK_METHOD3(SetStream, void(int32_t id, const uint8_t* ptr, size_t size)); MOCK_METHOD4(
MOCK_METHOD4(SetEncryptedStream, SetStream,
void(int32_t id, void(int32_t id, const uint8_t* ptr, size_t size, const DecryptConfig*));
const uint8_t* ptr,
size_t size,
const DecryptConfig& config));
MOCK_METHOD0(Flush, bool()); MOCK_METHOD0(Flush, bool());
MOCK_METHOD0(Reset, void()); MOCK_METHOD0(Reset, void());
MOCK_METHOD0(Decode, DecodeResult()); MOCK_METHOD0(Decode, DecodeResult());
...@@ -201,7 +198,7 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<VideoCodecProfile>, ...@@ -201,7 +198,7 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<VideoCodecProfile>,
::testing::InSequence s; ::testing::InSequence s;
base::RunLoop run_loop; base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure(); base::Closure quit_closure = run_loop.QuitClosure();
EXPECT_CALL(*mock_decoder_, SetStream(_, _, kInputSize)); EXPECT_CALL(*mock_decoder_, SetStream(_, _, kInputSize, nullptr));
EXPECT_CALL(*mock_decoder_, Decode()) EXPECT_CALL(*mock_decoder_, Decode())
.WillOnce(Return(AcceleratedVideoDecoder::kAllocateNewSurfaces)); .WillOnce(Return(AcceleratedVideoDecoder::kAllocateNewSurfaces));
...@@ -280,7 +277,7 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<VideoCodecProfile>, ...@@ -280,7 +277,7 @@ class VaapiVideoDecodeAcceleratorTest : public TestWithParam<VideoCodecProfile>,
void DecodeOneFrameFast(int32_t bitstream_id) { void DecodeOneFrameFast(int32_t bitstream_id) {
base::RunLoop run_loop; base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure(); base::Closure quit_closure = run_loop.QuitClosure();
EXPECT_CALL(*mock_decoder_, SetStream(_, _, kInputSize)); EXPECT_CALL(*mock_decoder_, SetStream(_, _, kInputSize, nullptr));
EXPECT_CALL(*mock_decoder_, Decode()) EXPECT_CALL(*mock_decoder_, Decode())
.WillOnce(Return(AcceleratedVideoDecoder::kRanOutOfStreamData)); .WillOnce(Return(AcceleratedVideoDecoder::kRanOutOfStreamData));
EXPECT_CALL(*this, NotifyEndOfBitstreamBuffer(bitstream_id)) EXPECT_CALL(*this, NotifyEndOfBitstreamBuffer(bitstream_id))
...@@ -363,7 +360,7 @@ TEST_P(VaapiVideoDecodeAcceleratorTest, QueueInputBufferAndDecodeError) { ...@@ -363,7 +360,7 @@ TEST_P(VaapiVideoDecodeAcceleratorTest, QueueInputBufferAndDecodeError) {
base::RunLoop run_loop; base::RunLoop run_loop;
base::Closure quit_closure = run_loop.QuitClosure(); base::Closure quit_closure = run_loop.QuitClosure();
EXPECT_CALL(*mock_decoder_, SetStream(_, _, kInputSize)); EXPECT_CALL(*mock_decoder_, SetStream(_, _, kInputSize, nullptr));
EXPECT_CALL(*mock_decoder_, Decode()) EXPECT_CALL(*mock_decoder_, Decode())
.WillOnce(Return(AcceleratedVideoDecoder::kDecodeError)); .WillOnce(Return(AcceleratedVideoDecoder::kDecodeError));
EXPECT_CALL(*this, NotifyError(VaapiVideoDecodeAccelerator::PLATFORM_FAILURE)) EXPECT_CALL(*this, NotifyError(VaapiVideoDecodeAccelerator::PLATFORM_FAILURE))
......
...@@ -27,9 +27,17 @@ bool VP8Decoder::Flush() { ...@@ -27,9 +27,17 @@ bool VP8Decoder::Flush() {
return true; return true;
} }
void VP8Decoder::SetStream(int32_t id, const uint8_t* ptr, size_t size) { void VP8Decoder::SetStream(int32_t id,
const uint8_t* ptr,
size_t size,
const DecryptConfig* decrypt_config) {
DCHECK(ptr); DCHECK(ptr);
DCHECK(size); DCHECK(size);
if (decrypt_config) {
NOTIMPLEMENTED();
state_ = kError;
return;
}
DVLOG(4) << "New input stream id: " << id << " at: " << (void*)ptr DVLOG(4) << "New input stream id: " << id << " at: " << (void*)ptr
<< " size: " << size; << " size: " << size;
...@@ -38,14 +46,6 @@ void VP8Decoder::SetStream(int32_t id, const uint8_t* ptr, size_t size) { ...@@ -38,14 +46,6 @@ void VP8Decoder::SetStream(int32_t id, const uint8_t* ptr, size_t size) {
frame_size_ = size; frame_size_ = size;
} }
void VP8Decoder::SetEncryptedStream(int32_t id,
const uint8_t* ptr,
size_t size,
const DecryptConfig& decrypt_config) {
state_ = kError;
NOTIMPLEMENTED();
}
void VP8Decoder::Reset() { void VP8Decoder::Reset() {
curr_frame_hdr_ = nullptr; curr_frame_hdr_ = nullptr;
curr_frame_start_ = nullptr; curr_frame_start_ = nullptr;
......
...@@ -63,11 +63,10 @@ class MEDIA_GPU_EXPORT VP8Decoder : public AcceleratedVideoDecoder { ...@@ -63,11 +63,10 @@ class MEDIA_GPU_EXPORT VP8Decoder : public AcceleratedVideoDecoder {
~VP8Decoder() override; ~VP8Decoder() override;
// AcceleratedVideoDecoder implementation. // AcceleratedVideoDecoder implementation.
void SetStream(int32_t id, const uint8_t* ptr, size_t size) override; void SetStream(int32_t id,
void SetEncryptedStream(int32_t id, const uint8_t* ptr,
const uint8_t* ptr, size_t size,
size_t size, const DecryptConfig* decrypt_config = nullptr) override;
const DecryptConfig& decrypt_config) override;
bool Flush() override WARN_UNUSED_RESULT; bool Flush() override WARN_UNUSED_RESULT;
void Reset() override; void Reset() override;
DecodeResult Decode() override WARN_UNUSED_RESULT; DecodeResult Decode() override WARN_UNUSED_RESULT;
......
...@@ -26,24 +26,23 @@ VP9Decoder::VP9Decoder(std::unique_ptr<VP9Accelerator> accelerator) ...@@ -26,24 +26,23 @@ VP9Decoder::VP9Decoder(std::unique_ptr<VP9Accelerator> accelerator)
VP9Decoder::~VP9Decoder() = default; VP9Decoder::~VP9Decoder() = default;
void VP9Decoder::SetStream(int32_t id, const uint8_t* ptr, size_t size) { void VP9Decoder::SetStream(int32_t id,
const uint8_t* ptr,
size_t size,
const DecryptConfig* decrypt_config) {
DCHECK(ptr); DCHECK(ptr);
DCHECK(size); DCHECK(size);
if (decrypt_config) {
NOTIMPLEMENTED();
state_ = kError;
return;
}
DVLOG(4) << "New input stream id: " << id << " at: " << (void*)ptr DVLOG(4) << "New input stream id: " << id << " at: " << (void*)ptr
<< " size: " << size; << " size: " << size;
stream_id_ = id; stream_id_ = id;
parser_.SetStream(ptr, size); parser_.SetStream(ptr, size);
} }
void VP9Decoder::SetEncryptedStream(int32_t id,
const uint8_t* ptr,
size_t size,
const DecryptConfig& decrypt_config) {
state_ = kError;
NOTIMPLEMENTED();
}
bool VP9Decoder::Flush() { bool VP9Decoder::Flush() {
DVLOG(2) << "Decoder flush"; DVLOG(2) << "Decoder flush";
Reset(); Reset();
......
...@@ -96,11 +96,10 @@ class MEDIA_GPU_EXPORT VP9Decoder : public AcceleratedVideoDecoder { ...@@ -96,11 +96,10 @@ class MEDIA_GPU_EXPORT VP9Decoder : public AcceleratedVideoDecoder {
~VP9Decoder() override; ~VP9Decoder() override;
// AcceleratedVideoDecoder implementation. // AcceleratedVideoDecoder implementation.
void SetStream(int32_t id, const uint8_t* ptr, size_t size) override; void SetStream(int32_t id,
void SetEncryptedStream(int32_t id, const uint8_t* ptr,
const uint8_t* ptr, size_t size,
size_t size, const DecryptConfig* decrypt_config = nullptr) override;
const DecryptConfig& decrypt_config) override;
bool Flush() override WARN_UNUSED_RESULT; bool Flush() override WARN_UNUSED_RESULT;
void Reset() override; void Reset() override;
DecodeResult Decode() override WARN_UNUSED_RESULT; DecodeResult Decode() override WARN_UNUSED_RESULT;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment