blob: 97de050104115d91d67fdf670485cf0a9c45d7e6 [file] [log] [blame]
philipel2fee4d62018-03-21 16:52:13 +01001/*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#ifndef VIDEO_VIDEO_STREAM_DECODER_IMPL_H_
12#define VIDEO_VIDEO_STREAM_DECODER_IMPL_H_
13
philipel2fee4d62018-03-21 16:52:13 +010014#include <map>
15#include <memory>
16#include <utility>
17
philipel2fee4d62018-03-21 16:52:13 +010018#include "api/video/video_stream_decoder.h"
philipel97187112018-03-23 10:43:21 +010019#include "modules/video_coding/frame_buffer2.h"
20#include "modules/video_coding/jitter_estimator.h"
21#include "modules/video_coding/timing.h"
22#include "rtc_base/task_queue.h"
23#include "rtc_base/thread_checker.h"
24#include "system_wrappers/include/clock.h"
philipel2fee4d62018-03-21 16:52:13 +010025
26namespace webrtc {
27
28class VideoStreamDecoderImpl : public VideoStreamDecoder,
29 private DecodedImageCallback {
30 public:
31 VideoStreamDecoderImpl(
32 VideoStreamDecoder::Callbacks* callbacks,
33 VideoDecoderFactory* decoder_factory,
34 std::map<int, std::pair<SdpVideoFormat, int>> decoder_settings);
35
36 ~VideoStreamDecoderImpl() override;
37
38 void OnFrame(std::unique_ptr<video_coding::EncodedFrame> frame) override;
39
40 private:
41 // Implements DecodedImageCallback interface
42 int32_t Decoded(VideoFrame& decodedImage) override;
43 int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override;
44 void Decoded(VideoFrame& decodedImage,
45 rtc::Optional<int32_t> decode_time_ms,
46 rtc::Optional<uint8_t> qp) override;
47
philipel97187112018-03-23 10:43:21 +010048 VideoStreamDecoder::Callbacks* const callbacks_
49 RTC_PT_GUARDED_BY(bookkeeping_queue_);
50 VideoDecoderFactory* const decoder_factory_;
philipel2fee4d62018-03-21 16:52:13 +010051 std::map<int, std::pair<SdpVideoFormat, int>> decoder_settings_;
philipel97187112018-03-23 10:43:21 +010052
53 // The |bookkeeping_queue_| is used to:
54 // - Make |callbacks_|.
55 // - Insert/extract frames from the |frame_buffer_|
56 // - Synchronize with whatever thread that makes the Decoded callback.
57 rtc::TaskQueue bookkeeping_queue_;
58
59 VCMJitterEstimator jitter_estimator_;
60 VCMTiming timing_;
61 video_coding::FrameBuffer frame_buffer_;
62 video_coding::VideoLayerFrameId last_continuous_id_;
philipel2fee4d62018-03-21 16:52:13 +010063};
64
65} // namespace webrtc
66
67#endif // VIDEO_VIDEO_STREAM_DECODER_IMPL_H_