Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions sdk/android/src/jni/videodecoderwrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ VideoDecoderWrapper::VideoDecoderWrapper(JNIEnv* jni,

{
decoder_thread_checker_.DetachFromThread();
dump_output_ = nullptr;
enable_dump_ = true;
}

VideoDecoderWrapper::~VideoDecoderWrapper() = default;
Expand All @@ -58,6 +60,16 @@ int32_t VideoDecoderWrapper::InitDecode(const VideoCodec* codec_settings,
JNIEnv* jni = AttachCurrentThreadIfNeeded();
codec_settings_ = *codec_settings;
number_of_cores_ = number_of_cores;

if(enable_dump_ && codec_settings_.codecType == kVideoCodecH264) {
std::string outfile = "/sdcard/dump_decoder_" + std::to_string(reinterpret_cast<long>(this)) + ".h264";
dump_output_ = fopen(outfile.c_str(), "wb");
if(dump_output_) {
RTC_LOG(LS_INFO) << "Open "<<outfile.c_str()<<"successed!";
}else{
RTC_LOG(LS_INFO) << "Open "<<outfile.c_str()<<"failed!";
}
}
return InitDecodeInternal(jni);
}

Expand Down Expand Up @@ -94,6 +106,10 @@ int32_t VideoDecoderWrapper::Decode(
return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
}

if(dump_output_){
fwrite((void*)(image_param._buffer), image_param._size, 1, dump_output_);
}

// Make a mutable copy so we can modify the timestamp.
EncodedImage input_image(image_param);
// We use RTP timestamp for capture time because capture_time_ms_ is always 0.
Expand Down Expand Up @@ -137,6 +153,10 @@ int32_t VideoDecoderWrapper::Release() {
rtc::CritScope cs(&frame_extra_infos_lock_);
frame_extra_infos_.clear();
}
if(dump_output_) {
fclose(dump_output_);
dump_output_ = nullptr;
}
initialized_ = false;
// It is allowed to reinitialize the codec on a different thread.
decoder_thread_checker_.DetachFromThread();
Expand Down
5 changes: 5 additions & 0 deletions sdk/android/src/jni/videodecoderwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <atomic>
#include <deque>

#include <fstream>
#include "api/video_codecs/video_decoder.h"
#include "common_video/h264/h264_bitstream_parser.h"
#include "rtc_base/race_checker.h"
Expand Down Expand Up @@ -108,6 +109,10 @@ class VideoDecoderWrapper : public VideoDecoder {
rtc::CriticalSection frame_extra_infos_lock_;
std::deque<FrameExtraInfo> frame_extra_infos_
RTC_GUARDED_BY(frame_extra_infos_lock_);

FILE* dump_output_;
bool enable_dump_;

};

/* If the j_decoder is a wrapped native decoder, unwrap it. If it is not,
Expand Down