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

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

Issue 2640153004: Add mailbox-based Mojo VideoFrame variant. (Closed)
Patch Set: Switch to an interface method. Created 3 years, 11 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
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 #ifndef MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_
6 #define MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ 6 #define MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/optional.h"
nasko 2017/02/16 21:37:29 Where is base::optional used here? Do we really ne
sandersd (OOO until July 31) 2017/02/25 01:19:38 Done.
12 #include "media/base/decode_status.h" 13 #include "media/base/decode_status.h"
13 #include "media/mojo/interfaces/video_decoder.mojom.h" 14 #include "media/mojo/interfaces/video_decoder.mojom.h"
14 15
16 namespace gpu {
17 struct SyncToken;
18 };
19
15 namespace media { 20 namespace media {
16 21
17 class MojoDecoderBufferReader; 22 class MojoDecoderBufferReader;
18 class MojoMediaClient; 23 class MojoMediaClient;
19 class VideoDecoder; 24 class VideoDecoder;
20 class VideoFrame; 25 class VideoFrame;
21 26
22 // Implementation of a mojom::VideoDecoder which runs in the GPU process, 27 // Implementation of a mojom::VideoDecoder which runs in the GPU process,
23 // and wraps a media::VideoDecoder. 28 // and wraps a media::VideoDecoder.
24 class MojoVideoDecoderService : public mojom::VideoDecoder { 29 class MojoVideoDecoderService : public mojom::VideoDecoder {
25 public: 30 public:
26 explicit MojoVideoDecoderService(MojoMediaClient* mojo_media_client); 31 explicit MojoVideoDecoderService(MojoMediaClient* mojo_media_client);
27 ~MojoVideoDecoderService() final; 32 ~MojoVideoDecoderService() final;
28 33
29 // mojom::VideoDecoder implementation 34 // mojom::VideoDecoder implementation
30 void Construct(mojom::VideoDecoderClientAssociatedPtrInfo client, 35 void Construct(mojom::VideoDecoderClientAssociatedPtrInfo client,
31 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe, 36 mojo::ScopedDataPipeConsumerHandle decoder_buffer_pipe,
32 mojom::CommandBufferIdPtr command_buffer_id) final; 37 mojom::CommandBufferIdPtr command_buffer_id) final;
33 void Initialize(mojom::VideoDecoderConfigPtr config, 38 void Initialize(mojom::VideoDecoderConfigPtr config,
34 bool low_delay, 39 bool low_delay,
35 const InitializeCallback& callback) final; 40 const InitializeCallback& callback) final;
36 void Decode(mojom::DecoderBufferPtr buffer, 41 void Decode(mojom::DecoderBufferPtr buffer,
37 const DecodeCallback& callback) final; 42 const DecodeCallback& callback) final;
38 void Reset(const ResetCallback& callback) final; 43 void Reset(const ResetCallback& callback) final;
44 void OnReleaseMailbox(const base::UnguessableToken& release_token,
45 const gpu::SyncToken& release_sync_token) final;
39 46
40 private: 47 private:
41 // Helper methods so that we can bind them with a weak pointer to avoid 48 // Helper methods so that we can bind them with a weak pointer to avoid
42 // running mojom::VideoDecoder callbacks after connection error happens and 49 // running mojom::VideoDecoder callbacks after connection error happens and
43 // |this| is deleted. It's not safe to run the callbacks after a connection 50 // |this| is deleted. It's not safe to run the callbacks after a connection
44 // error. 51 // error.
45 void OnDecoderInitialized(const InitializeCallback& callback, bool success); 52 void OnDecoderInitialized(const InitializeCallback& callback, bool success);
46 void OnDecoderRead(const DecodeCallback& callback, 53 void OnDecoderRead(const DecodeCallback& callback,
47 scoped_refptr<DecoderBuffer> buffer); 54 scoped_refptr<DecoderBuffer> buffer);
48 void OnDecoderDecoded(const DecodeCallback& callback, DecodeStatus status); 55 void OnDecoderDecoded(const DecodeCallback& callback, DecodeStatus status);
49 void OnDecoderReset(const ResetCallback& callback); 56 void OnDecoderReset(const ResetCallback& callback);
50 57
51 void OnDecoderOutput(const scoped_refptr<VideoFrame>& frame); 58 void OnDecoderOutput(const scoped_refptr<VideoFrame>& frame);
52 59
53 mojom::VideoDecoderClientAssociatedPtr client_; 60 mojom::VideoDecoderClientAssociatedPtr client_;
54 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; 61 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_;
55 62
56 MojoMediaClient* mojo_media_client_; 63 MojoMediaClient* mojo_media_client_;
57 std::unique_ptr<media::VideoDecoder> decoder_; 64 std::unique_ptr<media::VideoDecoder> decoder_;
58 65
59 base::WeakPtr<MojoVideoDecoderService> weak_this_; 66 base::WeakPtr<MojoVideoDecoderService> weak_this_;
60 base::WeakPtrFactory<MojoVideoDecoderService> weak_factory_; 67 base::WeakPtrFactory<MojoVideoDecoderService> weak_factory_;
61 68
62 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoderService); 69 DISALLOW_COPY_AND_ASSIGN(MojoVideoDecoderService);
63 }; 70 };
64 71
65 } // namespace media 72 } // namespace media
66 73
67 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_ 74 #endif // MEDIA_MOJO_SERVICES_MOJO_VIDEO_DECODER_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698