Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: media/mojo/services/mojo_video_decoder_service.cc

Issue 2429723006: MojoVideoDecoder: Plumb metadata methods. (Closed)
Patch Set: Actually early return. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/mojo/interfaces/video_decoder.mojom ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "media/mojo/services/mojo_video_decoder_service.h" 5 #include "media/mojo/services/mojo_video_decoder_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 19 matching lines...) Expand all
30 MojoVideoDecoderService::~MojoVideoDecoderService() {} 30 MojoVideoDecoderService::~MojoVideoDecoderService() {}
31 31
32 void MojoVideoDecoderService::Construct( 32 void MojoVideoDecoderService::Construct(
33 mojom::VideoDecoderClientAssociatedPtrInfo client, 33 mojom::VideoDecoderClientAssociatedPtrInfo client,
34 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe) { 34 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe) {
35 DVLOG(1) << __FUNCTION__; 35 DVLOG(1) << __FUNCTION__;
36 36
37 if (decoder_) 37 if (decoder_)
38 return; 38 return;
39 39
40 // TODO(sandersd): Provide callback for requesting a stub. 40 // TODO(sandersd): Provide callback for requesting a GpuCommandBufferStub.
41 decoder_ = mojo_media_client_->CreateVideoDecoder( 41 decoder_ = mojo_media_client_->CreateVideoDecoder(
42 base::ThreadTaskRunnerHandle::Get()); 42 base::ThreadTaskRunnerHandle::Get());
43 43
44 client_.Bind(std::move(client)); 44 client_.Bind(std::move(client));
45 45
46 mojo_decoder_buffer_reader_.reset( 46 mojo_decoder_buffer_reader_.reset(
47 new MojoDecoderBufferReader(std::move(decoder_buffer_pipe))); 47 new MojoDecoderBufferReader(std::move(decoder_buffer_pipe)));
48 } 48 }
49 49
50 void MojoVideoDecoderService::Initialize(mojom::VideoDecoderConfigPtr config, 50 void MojoVideoDecoderService::Initialize(mojom::VideoDecoderConfigPtr config,
51 bool low_delay, 51 bool low_delay,
52 const InitializeCallback& callback) { 52 const InitializeCallback& callback) {
53 DVLOG(1) << __FUNCTION__; 53 DVLOG(1) << __FUNCTION__;
54 54
55 if (!decoder_) { 55 if (!decoder_) {
56 callback.Run(false); 56 callback.Run(false, false, 1);
57 return; 57 return;
58 } 58 }
59 59
60 decoder_->Initialize( 60 decoder_->Initialize(
61 config.To<VideoDecoderConfig>(), low_delay, nullptr, 61 config.To<VideoDecoderConfig>(), low_delay, nullptr,
62 base::Bind(&MojoVideoDecoderService::OnDecoderInitialized, weak_this_, 62 base::Bind(&MojoVideoDecoderService::OnDecoderInitialized, weak_this_,
63 callback), 63 callback),
64 base::Bind(&MojoVideoDecoderService::OnDecoderOutput, weak_this_)); 64 base::Bind(&MojoVideoDecoderService::OnDecoderOutput, weak_this_));
65 } 65 }
66 66
67 void MojoVideoDecoderService::Decode(mojom::DecoderBufferPtr buffer, 67 void MojoVideoDecoderService::Decode(mojom::DecoderBufferPtr buffer,
68 const DecodeCallback& callback) { 68 const DecodeCallback& callback) {
69 DVLOG(1) << __FUNCTION__; 69 DVLOG(2) << __FUNCTION__;
70 70
71 if (!decoder_) { 71 if (!decoder_) {
72 callback.Run(DecodeStatus::DECODE_ERROR); 72 callback.Run(DecodeStatus::DECODE_ERROR);
73 return; 73 return;
74 } 74 }
75 75
76 // TODO(sandersd): After a decode error, we should enter an error state and 76 // TODO(sandersd): After a decode error, we should enter an error state and
77 // reject all future method calls. 77 // reject all future method calls.
78 scoped_refptr<DecoderBuffer> media_buffer = 78 scoped_refptr<DecoderBuffer> media_buffer =
79 mojo_decoder_buffer_reader_->ReadDecoderBuffer(buffer); 79 mojo_decoder_buffer_reader_->ReadDecoderBuffer(buffer);
(...skipping 16 matching lines...) Expand all
96 } 96 }
97 97
98 decoder_->Reset(base::Bind(&MojoVideoDecoderService::OnDecoderReset, 98 decoder_->Reset(base::Bind(&MojoVideoDecoderService::OnDecoderReset,
99 weak_this_, callback)); 99 weak_this_, callback));
100 } 100 }
101 101
102 void MojoVideoDecoderService::OnDecoderInitialized( 102 void MojoVideoDecoderService::OnDecoderInitialized(
103 const InitializeCallback& callback, 103 const InitializeCallback& callback,
104 bool success) { 104 bool success) {
105 DVLOG(1) << __FUNCTION__; 105 DVLOG(1) << __FUNCTION__;
106 callback.Run(success); 106 DCHECK(decoder_);
107 callback.Run(success, decoder_->NeedsBitstreamConversion(),
108 decoder_->GetMaxDecodeRequests());
107 } 109 }
108 110
109 void MojoVideoDecoderService::OnDecoderDecoded(const DecodeCallback& callback, 111 void MojoVideoDecoderService::OnDecoderDecoded(const DecodeCallback& callback,
110 DecodeStatus status) { 112 DecodeStatus status) {
111 DVLOG(1) << __FUNCTION__; 113 DVLOG(2) << __FUNCTION__;
114 DCHECK(decoder_);
115 DCHECK(decoder_->CanReadWithoutStalling());
112 callback.Run(status); 116 callback.Run(status);
113 } 117 }
114 118
115 void MojoVideoDecoderService::OnDecoderReset(const ResetCallback& callback) { 119 void MojoVideoDecoderService::OnDecoderReset(const ResetCallback& callback) {
116 DVLOG(1) << __FUNCTION__; 120 DVLOG(1) << __FUNCTION__;
117 callback.Run(); 121 callback.Run();
118 } 122 }
119 123
120 void MojoVideoDecoderService::OnDecoderOutput( 124 void MojoVideoDecoderService::OnDecoderOutput(
121 const scoped_refptr<VideoFrame>& frame) { 125 const scoped_refptr<VideoFrame>& frame) {
122 DVLOG(1) << __FUNCTION__; 126 DVLOG(2) << __FUNCTION__;
123 DCHECK(client_); 127 DCHECK(client_);
124 client_->OnVideoFrameDecoded(mojom::VideoFrame::From(frame)); 128 client_->OnVideoFrameDecoded(mojom::VideoFrame::From(frame));
125 } 129 }
126 130
127 } // namespace media 131 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/interfaces/video_decoder.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698