Skip to content

Commit

Permalink
fix #246 ffmpeg file source rtp timestamp calc
Browse files Browse the repository at this point in the history
  • Loading branch information
ireader committed Nov 19, 2022
1 parent e8163ea commit 37f7642
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions librtsp/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,22 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../sdk/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../sdk/libhttp/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../librtp/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../libmpeg/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../libflv/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../libmov/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../avcodec/avbsf/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../avcodec/avcodec/include

LOCAL_SRC_FILES += $(wildcard source/*.c)
LOCAL_SRC_FILES += $(wildcard source/*.cpp)
LOCAL_SRC_FILES += $(wildcard source/client/*.c)
LOCAL_SRC_FILES += $(wildcard source/client/*.cpp)
LOCAL_SRC_FILES += $(wildcard source/server/*.c)
LOCAL_SRC_FILES += $(wildcard source/server/*.cpp)
LOCAL_SRC_FILES += $(wildcard source/utils/*.c)
LOCAL_SRC_FILES += $(wildcard source/utils/*.cpp)
LOCAL_SRC_FILES += $(wildcard source/sdp/*.c)
LOCAL_SRC_FILES += $(wildcard source/sdp/*.cpp)

LOCAL_MODULE := rtsp
include $(BUILD_STATIC_LIBRARY)
6 changes: 3 additions & 3 deletions librtsp/test/media/ffmpeg-file-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,9 @@ int FFFileSource::Play()
if (-1 == m->dts_first)
m->dts_first = m_pkt.pts;
m->dts_last = m_pkt.pts;
uint32_t timestamp = m->timestamp + m->dts_last - m->dts_first;

rtp_payload_encode_input(m->packer, m_pkt.data, m_pkt.size, (uint32_t)(timestamp * (m->frequency / 1000) /*kHz*/));
uint32_t timestamp = m->timestamp + (uint32_t)((m->dts_last - m->dts_first) * (m->frequency / 1000) /*kHz*/);
//printf("[%s] pts: %lld, dts: %lld, timestamp: %u(%u)\n", m->name, m_pkt.pts, m_pkt.dts, (unsigned int)timestamp, (unsigned int)m->timestamp);
rtp_payload_encode_input(m->packer, m_pkt.data, m_pkt.size, timestamp);

av_packet_unref(&m_pkt); // send flag
sendframe = 1;
Expand Down
2 changes: 1 addition & 1 deletion librtsp/test/media/mp4-file-source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ int MP4FileSource::Play()
m->dts_first = pkt->pts;
m->dts_last = pkt->pts;
uint32_t timestamp = m->rtp.timestamp + (uint32_t)((m->dts_last - m->dts_first) * (m->rtp.frequency / 1000) /*kHz*/);
//printf("[%d] pts: %lld, dts: %lld, clock: %u\n", pkt->stream, pkt->pts, pkt->dts, timestamp);
//printf("[%s] pts: %lld, dts: %lld, timestamp: %u(%u)\n", m->rtp.encoding, pkt->pts, pkt->dts, (unsigned int)timestamp, (unsigned int)m->timestamp);
rtp_payload_encode_input(m->rtp.encoder, m_packet, bytes, timestamp);

avpacket_queue_pop(m->pkts);
Expand Down

0 comments on commit 37f7642

Please sign in to comment.