Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 70d75f7

Browse files
Yu, DingfengU1X6WK
authored andcommitted
Add bitstream dump option
Signed-off-by: Yu, Dingfeng <[email protected]>
1 parent f0ef7bf commit 70d75f7

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

src/player/app/linux/config.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<ProjectionType>ERP</ProjectionType>
2929
<frameRate>30</frameRate>
3030
<frameNum>100</frameNum>
31+
<enableDump>false</enableDump>
3132
<predict enable="0">
3233
<!-- <plugin>libViewportPredict_LR.so</plugin>
3334
<path>../plugins/ViewportPredict_Plugin/predict_LR/</path> -->

src/player/player_lib/MediaSource/WebRTCMediaSource.cpp

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,10 @@ WebRTCMediaSource::WebRTCMediaSource()
243243
m_pitch(0),
244244
m_rtcp_feedback(nullptr),
245245
m_parserRWPKHandle(nullptr),
246-
m_ready(false) {
246+
m_ready(false),
247+
m_enableBsDump(false),
248+
m_bsDumpfp(nullptr) {
249+
247250
LOG(INFO) << __FUNCTION__ << std::endl;
248251

249252
s_CurObj = this;
@@ -260,6 +263,11 @@ WebRTCMediaSource::~WebRTCMediaSource() {
260263
I360SCVP_unInit(m_parserRWPKHandle);
261264
m_parserRWPKHandle = nullptr;
262265
}
266+
267+
if (m_bsDumpfp) {
268+
fclose(m_bsDumpfp);
269+
m_bsDumpfp = nullptr;
270+
}
263271
}
264272

265273
void WebRTCMediaSource::parseOptions() {
@@ -284,6 +292,11 @@ void WebRTCMediaSource::parseOptions() {
284292
exit(-1);
285293
}
286294
m_serverAddress = std::string(server_url);
295+
296+
if (!strcmp(info->FirstChildElement("enableDump")->GetText(), "true")) {
297+
m_enableBsDump = true;
298+
}
299+
287300
}
288301

289302
void WebRTCMediaSource::setMediaInfo() {
@@ -336,10 +349,31 @@ void WebRTCMediaSource::setMediaInfo() {
336349
}
337350
}
338351

352+
void WebRTCMediaSource::initDump() {
353+
if (m_enableBsDump) {
354+
char dumpFileName[128];
355+
snprintf(dumpFileName, 128, "/tmp/webrtcsource-%p.%s", this, "hevc");
356+
m_bsDumpfp = fopen(dumpFileName, "wb");
357+
if (m_bsDumpfp) {
358+
LOG(INFO) << "Enable bitstream dump " << dumpFileName << std::endl;
359+
} else {
360+
LOG(ERROR) << "Can not open dump file " << dumpFileName << std::endl;
361+
}
362+
}
363+
}
364+
365+
void WebRTCMediaSource::dump(const uint8_t* buf, int len, FILE* fp) {
366+
if (fp) {
367+
fwrite(buf, 1, len, fp);
368+
fflush(fp);
369+
}
370+
}
371+
339372
RenderStatus WebRTCMediaSource::Initialize(struct RenderConfig renderConfig,
340373
RenderSourceFactory* rsFactory) {
341374
m_rsFactory = rsFactory;
342375
setMediaInfo();
376+
initDump();
343377

344378
m_DecoderManager = std::make_shared<DecoderManager>();
345379
RenderStatus ret = m_DecoderManager->Initialize(rsFactory);
@@ -466,6 +500,9 @@ bool WebRTCMediaSource::OnVideoPacket(
466500
std::shared_ptr<SimpleBuffer> bitstream_buf =
467501
std::make_shared<SimpleBuffer>();
468502
bitstream_buf->insert(frame->buffer, frame->length);
503+
if (m_enableBsDump) {
504+
dump(frame->buffer, frame->length, m_bsDumpfp);
505+
}
469506

470507
std::shared_ptr<SimpleBuffer> sei_buf = std::make_shared<SimpleBuffer>();
471508
filter_RWPK_SEI(bitstream_buf, sei_buf);

src/player/player_lib/MediaSource/WebRTCMediaSource.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ class WebRTCMediaSource : public MediaSource, public WebRTCVideoPacketListener {
161161
private:
162162
void parseOptions();
163163
void setMediaInfo();
164+
void initDump();
165+
void dump(const uint8_t* buf, int len, FILE* fp);
164166

165167
int32_t m_source_width;
166168
int32_t m_source_height;
@@ -187,6 +189,8 @@ class WebRTCMediaSource : public MediaSource, public WebRTCVideoPacketListener {
187189
void* m_parserRWPKHandle;
188190

189191
bool m_ready;
192+
bool m_enableBsDump;
193+
FILE* m_bsDumpfp;
190194
};
191195

192196
class SimpleBuffer {

0 commit comments

Comments
 (0)