2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-02-13 09:03:53 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_VIDEO_CODING_VIDEO_CODING_IMPL_H_
|
|
|
|
|
#define MODULES_VIDEO_CODING_VIDEO_CODING_IMPL_H_
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-02-29 05:51:59 -08:00
|
|
|
#include <memory>
|
2016-05-02 11:35:24 -07:00
|
|
|
#include <string>
|
2012-10-08 07:06:53 +00:00
|
|
|
#include <vector>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2018-11-15 17:52:43 +01:00
|
|
|
#include "absl/types/optional.h"
|
2018-02-20 16:09:48 +01:00
|
|
|
#include "modules/video_coding/decoder_database.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/video_coding/frame_buffer.h"
|
|
|
|
|
#include "modules/video_coding/generic_decoder.h"
|
|
|
|
|
#include "modules/video_coding/include/video_coding.h"
|
|
|
|
|
#include "modules/video_coding/jitter_buffer.h"
|
|
|
|
|
#include "modules/video_coding/receiver.h"
|
|
|
|
|
#include "modules/video_coding/timing.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/one_time_event.h"
|
2020-07-07 12:17:12 +02:00
|
|
|
#include "rtc_base/synchronization/mutex.h"
|
2019-04-09 13:44:04 +02:00
|
|
|
#include "rtc_base/synchronization/sequence_checker.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/thread_annotations.h"
|
|
|
|
|
#include "system_wrappers/include/clock.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2013-09-14 00:25:28 +00:00
|
|
|
namespace webrtc {
|
2013-11-26 11:41:59 +00:00
|
|
|
|
2016-11-16 16:41:30 +01:00
|
|
|
class VideoBitrateAllocator;
|
2016-12-01 06:34:11 -08:00
|
|
|
class VideoBitrateAllocationObserver;
|
2016-11-16 16:41:30 +01:00
|
|
|
|
2013-09-14 00:25:28 +00:00
|
|
|
namespace vcm {
|
|
|
|
|
|
|
|
|
|
class VCMProcessTimer {
|
|
|
|
|
public:
|
2016-11-21 05:41:52 -08:00
|
|
|
static const int64_t kDefaultProcessIntervalMs = 1000;
|
|
|
|
|
|
2014-12-15 22:09:40 +00:00
|
|
|
VCMProcessTimer(int64_t periodMs, Clock* clock)
|
2013-09-14 00:25:28 +00:00
|
|
|
: _clock(clock),
|
|
|
|
|
_periodMs(periodMs),
|
|
|
|
|
_latestMs(_clock->TimeInMilliseconds()) {}
|
2014-12-15 22:09:40 +00:00
|
|
|
int64_t Period() const;
|
|
|
|
|
int64_t TimeUntilProcess() const;
|
2013-09-14 00:25:28 +00:00
|
|
|
void Processed();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Clock* _clock;
|
2014-12-15 22:09:40 +00:00
|
|
|
int64_t _periodMs;
|
2013-09-14 00:25:28 +00:00
|
|
|
int64_t _latestMs;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
|
|
|
|
|
2016-04-22 18:23:15 +02:00
|
|
|
class VideoReceiver : public Module {
|
2013-09-14 00:25:28 +00:00
|
|
|
public:
|
2019-03-29 14:30:53 +01:00
|
|
|
VideoReceiver(Clock* clock, VCMTiming* timing);
|
2018-02-21 15:56:05 +01:00
|
|
|
~VideoReceiver() override;
|
2013-09-14 00:25:28 +00:00
|
|
|
|
2020-08-07 16:19:56 +02:00
|
|
|
int32_t RegisterReceiveCodec(uint8_t payload_type,
|
|
|
|
|
const VideoCodec* receiveCodec,
|
2020-08-07 14:14:49 +02:00
|
|
|
int32_t numberOfCores);
|
2013-09-14 00:25:28 +00:00
|
|
|
|
2015-11-27 14:09:07 +01:00
|
|
|
void RegisterExternalDecoder(VideoDecoder* externalDecoder,
|
2015-12-10 09:27:38 -08:00
|
|
|
uint8_t payloadType);
|
2013-09-14 00:25:28 +00:00
|
|
|
int32_t RegisterReceiveCallback(VCMReceiveCallback* receiveCallback);
|
|
|
|
|
int32_t RegisterFrameTypeCallback(VCMFrameTypeCallback* frameTypeCallback);
|
|
|
|
|
int32_t RegisterPacketRequestCallback(VCMPacketRequestCallback* callback);
|
|
|
|
|
|
|
|
|
|
int32_t Decode(uint16_t maxWaitTimeMs);
|
|
|
|
|
|
|
|
|
|
int32_t IncomingPacket(const uint8_t* incomingPayload,
|
Use size_t more consistently for packet/payload lengths.
See design doc at https://docs.google.com/a/chromium.org/document/d/1I6nmE9D_BmCY-IoV6MDPY2V6WYpEI-dg2apWXTfZyUI/edit?usp=sharing for more information.
This CL was reviewed and approved in pieces in the following CLs:
https://webrtc-codereview.appspot.com/24209004/
https://webrtc-codereview.appspot.com/24229004/
https://webrtc-codereview.appspot.com/24259004/
https://webrtc-codereview.appspot.com/25109004/
https://webrtc-codereview.appspot.com/26099004/
https://webrtc-codereview.appspot.com/27069004/
https://webrtc-codereview.appspot.com/27969004/
https://webrtc-codereview.appspot.com/27989004/
https://webrtc-codereview.appspot.com/29009004/
https://webrtc-codereview.appspot.com/30929004/
https://webrtc-codereview.appspot.com/30939004/
https://webrtc-codereview.appspot.com/31999004/
Committing as TBR to the original reviewers.
BUG=chromium:81439
TEST=none
TBR=pthatcher,henrik.lundin,tina.legrand,stefan,tkchin,glaznev,kjellander,perkj,mflodman,henrika,asapersson,niklas.enbom
Review URL: https://webrtc-codereview.appspot.com/23129004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@7726 4adac7df-926f-26a2-2b94-8c16560cd09d
2014-11-20 22:28:14 +00:00
|
|
|
size_t payloadLength,
|
2019-04-25 10:02:52 +02:00
|
|
|
const RTPHeader& rtp_header,
|
|
|
|
|
const RTPVideoHeader& video_header);
|
2013-09-14 00:25:28 +00:00
|
|
|
|
|
|
|
|
void SetNackSettings(size_t max_nack_list_size,
|
|
|
|
|
int max_packet_age_to_nack,
|
|
|
|
|
int max_incomplete_time_ms);
|
|
|
|
|
|
2016-04-22 18:23:15 +02:00
|
|
|
int64_t TimeUntilNextProcess() override;
|
|
|
|
|
void Process() override;
|
2018-02-21 15:56:05 +01:00
|
|
|
void ProcessThreadAttached(ProcessThread* process_thread) override;
|
2013-09-14 00:25:28 +00:00
|
|
|
|
|
|
|
|
protected:
|
2018-02-21 15:56:05 +01:00
|
|
|
int32_t Decode(const webrtc::VCMEncodedFrame& frame);
|
2013-09-14 00:25:28 +00:00
|
|
|
int32_t RequestKeyFrame();
|
|
|
|
|
|
|
|
|
|
private:
|
2018-02-21 15:56:05 +01:00
|
|
|
// Used for DCHECKing thread correctness.
|
|
|
|
|
// In build where DCHECKs are enabled, will return false before
|
|
|
|
|
// DecoderThreadStarting is called, then true until DecoderThreadStopped
|
|
|
|
|
// is called.
|
|
|
|
|
// In builds where DCHECKs aren't enabled, it will return true.
|
|
|
|
|
bool IsDecoderThreadRunning();
|
|
|
|
|
|
2021-02-02 10:57:19 +01:00
|
|
|
SequenceChecker construction_thread_checker_;
|
|
|
|
|
SequenceChecker decoder_thread_checker_;
|
|
|
|
|
SequenceChecker module_thread_checker_;
|
2014-07-04 10:58:12 +00:00
|
|
|
Clock* const clock_;
|
2020-07-07 12:17:12 +02:00
|
|
|
Mutex process_mutex_;
|
2016-12-15 07:10:57 -08:00
|
|
|
VCMTiming* _timing;
|
2013-09-14 00:25:28 +00:00
|
|
|
VCMReceiver _receiver;
|
|
|
|
|
VCMDecodedFrameCallback _decodedFrameCallback;
|
2016-04-15 01:24:14 -07:00
|
|
|
|
2018-02-21 15:56:05 +01:00
|
|
|
// These callbacks are set on the construction thread before being attached
|
|
|
|
|
// to the module thread or decoding started, so a lock is not required.
|
|
|
|
|
VCMFrameTypeCallback* _frameTypeCallback;
|
|
|
|
|
VCMPacketRequestCallback* _packetRequestCallback;
|
|
|
|
|
|
|
|
|
|
// Used on both the module and decoder thread.
|
2020-07-07 12:17:12 +02:00
|
|
|
bool _scheduleKeyRequest RTC_GUARDED_BY(process_mutex_);
|
|
|
|
|
bool drop_frames_until_keyframe_ RTC_GUARDED_BY(process_mutex_);
|
2016-02-02 15:40:04 +01:00
|
|
|
|
2018-02-21 15:56:05 +01:00
|
|
|
// Modified on the construction thread while not attached to the process
|
|
|
|
|
// thread. Once attached to the process thread, its value is only read
|
|
|
|
|
// so a lock is not required.
|
|
|
|
|
size_t max_nack_list_size_;
|
|
|
|
|
|
|
|
|
|
// Callbacks are set before the decoder thread starts.
|
|
|
|
|
// Once the decoder thread has been started, usage of |_codecDataBase| moves
|
|
|
|
|
// over to the decoder thread.
|
|
|
|
|
VCMDecoderDataBase _codecDataBase;
|
|
|
|
|
|
|
|
|
|
VCMProcessTimer _retransmissionTimer RTC_GUARDED_BY(module_thread_checker_);
|
|
|
|
|
VCMProcessTimer _keyRequestTimer RTC_GUARDED_BY(module_thread_checker_);
|
|
|
|
|
ThreadUnsafeOneTimeEvent first_frame_received_
|
|
|
|
|
RTC_GUARDED_BY(decoder_thread_checker_);
|
|
|
|
|
// Modified on the construction thread. Can be read without a lock and assumed
|
|
|
|
|
// to be non-null on the module and decoder threads.
|
|
|
|
|
ProcessThread* process_thread_ = nullptr;
|
|
|
|
|
bool is_attached_to_process_thread_
|
|
|
|
|
RTC_GUARDED_BY(construction_thread_checker_) = false;
|
2011-07-07 08:21:25 +00:00
|
|
|
};
|
2013-09-14 00:25:28 +00:00
|
|
|
|
|
|
|
|
} // namespace vcm
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_VIDEO_CODING_VIDEO_CODING_IMPL_H_
|