Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / media / cast / receiver / video_decoder.h
blobf3d8ca202ea635708aceba2e9ac00255b8a60707
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_CAST_RECEIVER_VIDEO_DECODER_H_
6 #define MEDIA_CAST_RECEIVER_VIDEO_DECODER_H_
8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "media/base/video_frame.h"
12 #include "media/cast/cast_config.h"
13 #include "media/cast/net/cast_transport_config.h"
15 namespace media {
16 namespace cast {
18 class CastEnvironment;
20 class VideoDecoder {
21 public:
22 // Callback passed to DecodeFrame, to deliver a decoded video frame from the
23 // decoder. |frame| can be NULL when errors occur. |is_continuous| is
24 // normally true, but will be false if the decoder has detected a frame skip
25 // since the last decode operation; and the client might choose to take steps
26 // to smooth/interpolate video discontinuities in this case.
27 typedef base::Callback<void(const scoped_refptr<VideoFrame>& frame,
28 bool is_continuous)> DecodeFrameCallback;
30 VideoDecoder(const scoped_refptr<CastEnvironment>& cast_environment,
31 Codec codec);
32 virtual ~VideoDecoder();
34 // Returns STATUS_VIDEO_INITIALIZED if the decoder was successfully
35 // constructed from the given FrameReceiverConfig. If this method returns any
36 // other value, calls to DecodeFrame() will not succeed.
37 CastInitializationStatus InitializationResult() const;
39 // Decode the payload in |encoded_frame| asynchronously. |callback| will be
40 // invoked on the CastEnvironment::MAIN thread with the result.
42 // In the normal case, |encoded_frame->frame_id| will be
43 // monotonically-increasing by 1 for each successive call to this method.
44 // When it is not, the decoder will assume one or more frames have been
45 // dropped (e.g., due to packet loss), and will perform recovery actions.
46 void DecodeFrame(scoped_ptr<EncodedFrame> encoded_frame,
47 const DecodeFrameCallback& callback);
49 private:
50 class FakeImpl;
51 class ImplBase;
52 class Vp8Impl;
54 const scoped_refptr<CastEnvironment> cast_environment_;
55 scoped_refptr<ImplBase> impl_;
57 DISALLOW_COPY_AND_ASSIGN(VideoDecoder);
60 } // namespace cast
61 } // namespace media
63 #endif // MEDIA_CAST_RECEIVER_VIDEO_DECODER_H_