Files
platform-external-webrtc/webrtc/modules/video_coding/generic_decoder.h
ilnik 27c46e2872 Revert of Add content type information to encoded images and corresponding rtp extension header (patchset #4 id:400001 of https://codereview.webrtc.org/2812913002/ )
Reason for revert:
Breaks android buildbots.

Original issue's description:
> Reland of Add content type information to encoded images and corresponding rtp extension header (patchset #1 id:1 of https://codereview.webrtc.org/2816463002/ )
>
> Reason for revert:
> Reland with appropriate changes to API to not break depending projects.
>
> Original issue's description:
> > Revert of Add content type information to encoded images and corresponding rtp extension header (patchset #31 id:600001 of https://codereview.webrtc.org/2772033002/ )
> >
> > Reason for revert:
> > Breaks dependent projects.
> >
> > Original issue's description:
> > > Add content type information to Encoded Images and add corresponding RTP extension header.
> > > Use it to separate UMA e2e delay metric between screenshare from video.
> > > Content type extension is set based on encoder settings and processed and decoders.
> > >
> > > Also,
> > > Fix full-stack-tests to calculate RTT correctly, so new metric could be tested.
> > >
> > > BUG=webrtc:7420
> > >
> > > Review-Url: https://codereview.webrtc.org/2772033002
> > > Cr-Commit-Position: refs/heads/master@{#17640}
> > > Committed: 64e739aeae
> >
> > TBR=tommi@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,nisse@webrtc.org,mflodman@webrtc.org
> > # Skipping CQ checks because original CL landed less than 1 days ago.
> > NOPRESUBMIT=true
> > NOTREECHECKS=true
> > NOTRY=true
> > BUG=webrtc:7420
> >
> > Review-Url: https://codereview.webrtc.org/2816463002
> > Cr-Commit-Position: refs/heads/master@{#17644}
> > Committed: 5721866808
>
> TBR=tommi@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,nisse@webrtc.org,mflodman@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:7420
>
> Review-Url: https://codereview.webrtc.org/2812913002
> Cr-Commit-Position: refs/heads/master@{#17651}
> Committed: 774f6b4b96

TBR=tommi@webrtc.org,sprang@webrtc.org,stefan@webrtc.org,nisse@webrtc.org,mflodman@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:7420

Review-Url: https://codereview.webrtc.org/2809653004
Cr-Commit-Position: refs/heads/master@{#17653}
2017-04-11 13:20:05 +00:00

117 lines
3.7 KiB
C++

/*
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
*
* 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.
*/
#ifndef WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_
#define WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/thread_checker.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/video_coding/encoded_frame.h"
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
#include "webrtc/modules/video_coding/timestamp_map.h"
#include "webrtc/modules/video_coding/timing.h"
namespace webrtc {
class VCMReceiveCallback;
enum { kDecoderFrameMemoryLength = 10 };
struct VCMFrameInformation {
int64_t renderTimeMs;
int64_t decodeStartTimeMs;
void* userData;
VideoRotation rotation;
};
class VCMDecodedFrameCallback : public DecodedImageCallback {
public:
VCMDecodedFrameCallback(VCMTiming* timing, Clock* clock);
~VCMDecodedFrameCallback() override;
void SetUserReceiveCallback(VCMReceiveCallback* receiveCallback);
VCMReceiveCallback* UserReceiveCallback();
int32_t Decoded(VideoFrame& decodedImage) override;
int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) override;
void Decoded(VideoFrame& decodedImage,
rtc::Optional<int32_t> decode_time_ms,
rtc::Optional<uint8_t> qp) override;
int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) override;
int32_t ReceivedDecodedFrame(const uint64_t pictureId) override;
uint64_t LastReceivedPictureID() const;
void OnDecoderImplementationName(const char* implementation_name);
void Map(uint32_t timestamp, VCMFrameInformation* frameInfo);
int32_t Pop(uint32_t timestamp);
private:
rtc::ThreadChecker construction_thread_;
// Protect |_timestampMap|.
Clock* const _clock;
// This callback must be set before the decoder thread starts running
// and must only be unset when external threads (e.g decoder thread)
// have been stopped. Due to that, the variable should regarded as const
// while there are more than one threads involved, it must be set
// from the same thread, and therfore a lock is not required to access it.
VCMReceiveCallback* _receiveCallback = nullptr;
VCMTiming* _timing;
rtc::CriticalSection lock_;
VCMTimestampMap _timestampMap GUARDED_BY(lock_);
uint64_t _lastReceivedPictureID;
};
class VCMGenericDecoder {
friend class VCMCodecDataBase;
public:
explicit VCMGenericDecoder(VideoDecoder* decoder, bool isExternal = false);
~VCMGenericDecoder();
/**
* Initialize the decoder with the information from the VideoCodec
*/
int32_t InitDecode(const VideoCodec* settings, int32_t numberOfCores);
/**
* Decode to a raw I420 frame,
*
* inputVideoBuffer reference to encoded video frame
*/
int32_t Decode(const VCMEncodedFrame& inputFrame, int64_t nowMs);
/**
* Free the decoder memory
*/
int32_t Release();
/**
* Set decode callback. Deregistering while decoding is illegal.
*/
int32_t RegisterDecodeCompleteCallback(VCMDecodedFrameCallback* callback);
bool External() const;
bool PrefersLateDecoding() const;
private:
VCMDecodedFrameCallback* _callback;
VCMFrameInformation _frameInfos[kDecoderFrameMemoryLength];
uint32_t _nextFrameInfoIdx;
VideoDecoder* const _decoder;
VideoCodecType _codecType;
bool _isExternal;
bool _keyFrameDecoded;
};
} // namespace webrtc
#endif // WEBRTC_MODULES_VIDEO_CODING_GENERIC_DECODER_H_