Skip to content

Commit c0ade3f

Browse files
committed
change: rtsp client play range npt/clock
1 parent c3865b7 commit c0ade3f

File tree

6 files changed

+25
-18
lines changed

6 files changed

+25
-18
lines changed

librtsp/source/client/rtsp-client-play.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Date: 23 Jan 1997 15:35:06 GMT
4040
#include "rtsp-header-range.h"
4141
#include "rtsp-header-rtp-info.h"
4242
#include <assert.h>
43+
#include <time.h>
4344

4445
static const char* sc_format =
4546
"PLAY %s RTSP/1.0\r\n"
@@ -51,6 +52,17 @@ static const char* sc_format =
5152
"User-Agent: %s\r\n"
5253
"\r\n";
5354

55+
int rtsp_header_range_write(char* s, int n, uint64_t npt)
56+
{
57+
time_t now;
58+
if (npt / 1000 < 946656000 /* 2000-01-01 00:00:00 */ ) {
59+
return snprintf(s, n, "Range: npt=%" PRIu64 ".%" PRIu64 "-\r\n", npt / 1000, npt % 1000);
60+
} else {
61+
now = npt / 1000; // ms -> s
62+
return strftime(s, n, "Range: clock=%Y%m%dT%H%M%SZ-\r\n", gmtime(&now));
63+
}
64+
}
65+
5466
static int rtsp_client_media_play(struct rtsp_client_t *rtsp, int i)
5567
{
5668
int r;
@@ -80,7 +92,7 @@ int rtsp_client_play(struct rtsp_client_t *rtsp, const uint64_t *npt, const floa
8092
#else
8193
if ((scale && snprintf(rtsp->scale, sizeof(rtsp->scale), "Speed: %.2f\r\nScale: %.2f\r\n", *scale, *scale) >= sizeof(rtsp->scale))
8294
#endif
83-
|| (npt && snprintf(rtsp->range, sizeof(rtsp->range), "Range: npt=%" PRIu64 ".%" PRIu64 "-\r\n", *npt / 1000, *npt % 1000) >= sizeof(rtsp->range)) )
95+
|| (npt && rtsp_header_range_write(rtsp->range, sizeof(rtsp->range), *npt) >= sizeof(rtsp->range)))
8496
return -1;
8597

8698
if(rtsp->aggregate)

librtsp/source/client/rtsp-client-record.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static const char* sc_format =
3939
"User-Agent: %s\r\n"
4040
"\r\n";
4141

42+
int rtsp_header_range_write(char* s, int n, uint64_t npt);
43+
4244
static int rtsp_client_media_record(struct rtsp_client_t *rtsp, int i)
4345
{
4446
int r;
@@ -68,7 +70,7 @@ int rtsp_client_record(struct rtsp_client_t *rtsp, const uint64_t *npt, const fl
6870
#else
6971
if ((scale && snprintf(rtsp->scale, sizeof(rtsp->scale), "Speed: %.2f\r\nScale: %.2f\r\n", *scale, *scale) >= sizeof(rtsp->scale))
7072
#endif
71-
|| (npt && snprintf(rtsp->range, sizeof(rtsp->range), "Range: npt=%" PRIu64 ".%" PRIu64 "-\r\n", *npt / 1000, *npt % 1000) >= sizeof(rtsp->range)))
73+
|| (npt && rtsp_header_range_write(rtsp->range, sizeof(rtsp->range), *npt) >= sizeof(rtsp->range)))
7274
return -1;
7375

7476
if (rtsp->aggregate)

test/Makefile

+2-16
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,6 @@ SOURCE_PATHS = . $(ROOT)/source/digest $(ROOT)/libhttp/test \
3939

4040
SOURCE_FILES = $(foreach dir,$(SOURCE_PATHS),$(wildcard $(dir)/*.cpp))
4141
SOURCE_FILES += $(foreach dir,$(SOURCE_PATHS),$(wildcard $(dir)/*.c))
42-
SOURCE_FILES += $(ROOT)/source/uri-parse.c
43-
SOURCE_FILES += $(ROOT)/source/urlcodec.c
44-
SOURCE_FILES += $(ROOT)/source/ntp-time.c
45-
SOURCE_FILES += $(ROOT)/source/time64.c
46-
SOURCE_FILES += $(ROOT)/source/base64.c
47-
SOURCE_FILES += $(ROOT)/source/unicode.c
48-
SOURCE_FILES += $(ROOT)/source/thread-pool.c
49-
SOURCE_FILES += $(ROOT)/source/app-log.c
50-
SOURCE_FILES += $(ROOT)/source/port/ip-route.c
51-
SOURCE_FILES += $(ROOT)/source/sockpair.c
52-
SOURCE_FILES += $(ROOT)/source/darray.c
53-
SOURCE_FILES += $(ROOT)/source/channel.c
54-
SOURCE_FILES += $(ROOT)/source/uuid.c
55-
SOURCE_FILES += $(ROOT)/source/random.c
56-
SOURCE_FILES += $(ROOT)/source/port/sysnetconfig.c
5742
SOURCE_FILES += $(ROOT)/libice/test/ice-transport.c
5843
SOURCE_FILES += $(ROOT)/deprecated/tools.c
5944

@@ -89,7 +74,8 @@ STATIC_LIBS = ../libdash/$(BUILD).$(PLATFORM)/libdash.a \
8974
$(AVCODEC)/avbsf/$(BUILD).$(PLATFORM)/libavbsf.a \
9075
$(AVCODEC)/avcodec/$(BUILD).$(PLATFORM)/libavcodec.a \
9176
$(AVCODEC)/h264/$(BUILD).$(PLATFORM)/libh264.a \
92-
$(AVCODEC)/h265/$(BUILD).$(PLATFORM)/libh265.a
77+
$(AVCODEC)/h265/$(BUILD).$(PLATFORM)/libh265.a \
78+
$(ROOT)/libsdk/$(BUILD).$(PLATFORM)/libsdk.a
9379

9480

9581
#-----------------------------DEFINES--------------------------------

test/test.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ DEF_FUN_PCHAR(mpeg_ts_dec_test, const char* file);
192192
DEF_FUN_PCHAR(mpeg_ts_test, const char* input);
193193
DEF_FUN_PCHAR(mpeg_ps_test, const char* input);
194194
DEF_FUN_PCHAR(mpeg_ps_2_flv_test, const char* ps);
195+
DEF_FUN_PCHAR(mov_2_mpeg_ps_test, const char* mp4);
195196
DEF_FUN_PCHAR(flv_2_mpeg_ps_test, const char* flv);
196197
DEF_FUN_PCHAR(mpeg_ps_dec_test, const char* file);
197198

@@ -220,6 +221,7 @@ extern "C" DEF_FUN_VOID(sip_header_test);
220221
extern "C" DEF_FUN_VOID(sip_agent_test);
221222
DEF_FUN_VOID(sip_uac_message_test);
222223
DEF_FUN_VOID(sip_uas_message_test);
224+
DEF_FUN_VOID(sip_message_test);
223225
DEF_FUN_VOID(sip_uac_test);
224226
DEF_FUN_VOID(sip_uas_test);
225227
DEF_FUN_VOID(sip_uac_test2);
@@ -262,6 +264,7 @@ int main(int argc, const char* argv[])
262264
RE_RUN_REG("http_header_www_authenticate_test", argc, argv);
263265
RE_RUN_REG("rtsp_client_auth_test", argc, argv);
264266
RE_RUN_REG("sip_header_test", argc, argv);
267+
RE_RUN_REG("sip_message_test", argc, argv);
265268
RE_RUN_REG("sip_uac_message_test", argc, argv);
266269
RE_RUN_REG("sip_uas_message_test", argc, argv);
267270
goto EXIT;

test/test.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@
222222
<ClCompile Include="..\libmov\test\mov-writer-subtitle.cpp" />
223223
<ClCompile Include="..\libmov\test\mov-writer-test.cpp" />
224224
<ClCompile Include="..\libmpeg\test\flv-2-mpeg-ps-test.cpp" />
225+
<ClCompile Include="..\libmpeg\test\mov-2-mpeg-ps-test.cpp" />
225226
<ClCompile Include="..\libmpeg\test\mpeg-ps-2-flv-test.cpp" />
226227
<ClCompile Include="..\libmpeg\test\mpeg-ps-dec-test.cpp" />
227228
<ClCompile Include="..\libmpeg\test\mpeg-ps-test.cpp" />

test/test.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,9 @@
518518
<ClCompile Include="..\librtsp\test\rtsp-client-test2.c">
519519
<Filter>librtsp</Filter>
520520
</ClCompile>
521+
<ClCompile Include="..\libmpeg\test\mov-2-mpeg-ps-test.cpp">
522+
<Filter>libmpeg</Filter>
523+
</ClCompile>
521524
</ItemGroup>
522525
<ItemGroup>
523526
<None Include="..\libflv\test\rtmp.onStatus.amf0">

0 commit comments

Comments
 (0)