#define MAX_STRING_LEN 2048
#define MAX_TRACK_COUNT 10
+
+#define TIME_SECOND ((gint64)(G_USEC_PER_SEC * G_GINT64_CONSTANT (1000)))
+#define TIME_USECOND ((gint64)(TIME_SECOND / G_GINT64_CONSTANT (1000000)))
+#define TIME_MSECOND ((gint64)(TIME_SECOND / G_GINT64_CONSTANT (1000)))
+#define TIME_USEC_TO_MSEC(time) ((time) / G_GINT64_CONSTANT (1000))
+
constexpr uint64_t SEEK_WAIT_TIME = 100 * G_TIME_SPAN_MILLISECOND;
// #define DEBUG_LOG
CURRENT_STATUS_SET_RENDER_TIME_OFFSET,
CURRENT_STATUS_SET_LOW_LATENCY_MODE,
CURRENT_STATUS_SET_SOUND_STREAM_INFO,
+ CURRENT_STATUS_SET_TIME_UNIT,
};
/* for video display */
int audio_track_id;
sound_stream_info_h stream_info;
bool is_seek_done;
+ esplusplayer_time_unit_type time_unit;
} test_h;
static appdata g_ad;
g_test_h->audio_track_id = -1;
g_test_h->video_track_id = -1;
g_test_h->is_seek_done = true;
+ g_test_h->time_unit = ESPLUSPLAYER_TIME_UNIT_MS;
__init_espp();
__init_demux();
bool is_audio;
uint64_t gst_pts;
uint64_t gst_duration;
+ int64_t time_scale = TIME_MSECOND;
if (!packet) {
g_print("media packet is NULL\n");
media_packet_get_buffer_size(packet, (uint64_t *)&espp_packet->buffer_size);
media_packet_get_pts(packet, &gst_pts);
media_packet_get_duration(packet, &gst_duration);
+ if (g_test_h->time_unit == ESPLUSPLAYER_TIME_UNIT_US)
+ time_scale = TIME_USECOND;
+
if (gst_pts != (uint64_t) -1)
- espp_packet->pts = gst_pts / G_GINT64_CONSTANT(1000000);
+ espp_packet->pts = gst_pts / time_scale;
if (gst_duration != (uint64_t) -1)
- espp_packet->duration = gst_duration / G_GINT64_CONSTANT(1000000);
+ espp_packet->duration = gst_duration / time_scale;
espp_packet->matroska_color_info = NULL;
espp_packet->hdr10p_metadata = NULL;
g_print(" => esplusplayer_pause() success\n");
}
-static void __test_seek(uint64_t time_ms)
+static void __test_seek(uint64_t time)
{
int i = 0;
int ret = 0;
STREAM_UNLOCK(i);
}
+ int64_t time_ms = (int64_t)time;
+ if (g_test_h->time_unit == ESPLUSPLAYER_TIME_UNIT_US)
+ time_ms = TIME_USEC_TO_MSEC(time);
+
ret = mediademuxer_seek(g_test_h->audio_demux_h, time_ms);
if (ret != MEDIADEMUXER_ERROR_NONE)
- g_print(" => failed to mediademuxer_seek(audio, %" PRIu64 ")\n", time_ms);
+ g_print(" => failed to mediademuxer_seek(audio, %" PRId64 " ms)\n", time_ms);
else
- g_print(" => mediademuxer_seek(audio, %" PRIu64 ") success\n", time_ms);
+ g_print(" => mediademuxer_seek(audio, %" PRId64 " ms) success\n", time_ms);
ret = mediademuxer_seek(g_test_h->video_demux_h, time_ms);
if (ret != MEDIADEMUXER_ERROR_NONE)
- g_print(" => failed to mediademuxer_seek(video, %" PRIu64 ")\n", time_ms);
+ g_print(" => failed to mediademuxer_seek(video, %" PRId64 " ms)\n", time_ms);
else
- g_print(" => mediademuxer_seek(video, %" PRIu64 ") success\n", time_ms);
+ g_print(" => mediademuxer_seek(video, %" PRId64 " ms) success\n", time_ms);
- ret = esplusplayer_seek(g_test_h->espp_h, time_ms);
+ ret = esplusplayer_seek(g_test_h->espp_h, time);
if (ret != ESPLUSPLAYER_ERROR_TYPE_NONE)
- g_print(" => failed to esplusplayer_seek(%" PRIu64 ")\n", time_ms);
+ g_print(" => failed to esplusplayer_seek(%" PRIu64 " (ms/us))\n", time);
else
- g_print(" => esplusplayer_seek(%" PRIu64 ") success\n", time_ms);
+ g_print(" => esplusplayer_seek(%" PRIu64 " (ms/us)) success\n", time);
}
static void __test_set_playback_rate(double playback_rate, bool audio_mute)
sound_manager_free_device_list(device_list);
}
+static void __test_set_time_unit(int time_unit)
+{
+ if (!g_test_h) {
+ g_print("test handle is NULL\n");
+ return;
+ }
+
+ if (time_unit < 0 || time_unit > 1) {
+ g_print("!!! Not support time unit (%d)\n", time_unit);
+ return;
+ }
+
+ g_test_h->time_unit = (esplusplayer_time_unit_type)time_unit;
+ int ret = esplusplayer_set_timeunit_type(g_test_h->espp_h, g_test_h->time_unit);
+ if (ret != ESPLUSPLAYER_ERROR_TYPE_NONE)
+ g_print(" => failed to esplusplayer_set_timeunit_type(%d)\n", g_test_h->time_unit);
+ else
+ g_print(" => esplusplayer_set_timeunit_type(%d) success\n", g_test_h->time_unit);
+}
+
+static void __test_get_playing_time()
+{
+ uint64_t time = 0;
+ if (!g_test_h) {
+ g_print("test handle is NULL\n");
+ return;
+ }
+
+ int ret = esplusplayer_get_playing_time(g_test_h->espp_h, &time);
+ if (ret != ESPLUSPLAYER_ERROR_TYPE_NONE)
+ g_print(" => failed to esplusplayer_get_playing_time(%" PRIu64 ")(ms/ns) success\n", time);
+ else
+ g_print(" => esplusplayer_get_playing_time(%" PRIu64 ")(ms/ns) success\n", time);
+}
+
static void __test_quick_prepare()
{
int ret = 0;
} else if (strncmp(cmd, "q", 1) == 0) {
quit_program();
} else if (strncmp(cmd, "3", 1) == 0) {
- if (g_max_range > 0)
- __test_seek(g_rand_int_range(g_seek_rand, 0, g_max_range));
+ if (g_max_range > 0) {
+ uint64_t seek_time = (uint64_t)g_rand_int_range(g_seek_rand, 0, g_max_range);
+ if (g_test_h->time_unit == ESPLUSPLAYER_TIME_UNIT_US)
+ seek_time = seek_time * G_GINT64_CONSTANT(1000);
+ __test_seek(seek_time);
+ }
g_menu_state = CURRENT_STATUS_MAINMENU;
} else {
g_print("unknown menu \n");
__test_quick_prepare();
} else if (strncmp(cmd, "ll", 2) == 0) {
g_menu_state = CURRENT_STATUS_SET_LOW_LATENCY_MODE;
+ } else if (strncmp(cmd, "st", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_SET_TIME_UNIT;
+ } else if (strncmp(cmd, "gp", 2) == 0) {
+ __test_get_playing_time();
} else {
g_print("unknown menu \n");
}
g_print("d.Resume\t");
g_print("e.Pause\t\t");
g_print("dt.Destroy\n");
+ g_print(" gp.Get playing time\n");
g_print("[quick] qp.quick prepare\n");
g_print("[seek] j.Seek\t");
g_print("3.Random seek\t");
g_print("g.Get Volume\t");
g_print("h.Set Mute\n");
g_print("[etc] ");
- g_print("sr.Set render time offset\t");
+ g_print("sr.Set render time offset\t\t");
g_print("ll.Set low latency mode\n");
- g_print(" ssi.Set sound stream info\n\n");
+ g_print(" ssi.Set sound stream info\t\t");
+ g_print("st.Set Time Unit\n\n");
g_print("-- << mediademuxer cmd >> ---------------------------------------------------------------\n");
g_print("prd.prepare demuxer\n\n");
g_print("-- << display >> ------------------------------------------------------------------------\n");
- g_print("ev.enable videohole\t\t");
+ g_print("ev.enable videohole\t");
g_print("ds.set display\t\t");
g_print("dm.set display mode\n");
g_print("dr.set display roi\t");
} else if (g_menu_state == CURRENT_STATUS_DEACTIVATE) {
g_print("*** Input deactivate stream.(0:audio, 1:video)\n");
} else if (g_menu_state == CURRENT_STATUS_SEEK) {
- g_print("*** Input seek position.(ms)\n");
+ g_print("*** Input seek position.(ms/us))\n");
} else if (g_menu_state == CURRENT_STATUS_SET_SEEK_RANGE) {
g_print("*** Input random seek range.(ms)\n");
} else if (g_menu_state == CURRENT_STATUS_SET_RATE) {
g_print("*** Input low latency mode (0: none, 1: disable preroll)\n");
} else if (g_menu_state == CURRENT_STATUS_SET_SOUND_STREAM_INFO) {
g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 9:MEDIA_EXT_ONLY)\n");
+ } else if (g_menu_state == CURRENT_STATUS_SET_TIME_UNIT) {
+ g_print("*** input time unit.(0:ms 1:us)\n");
} else {
g_print("*** Unknown status.\n");
quit_program();
reset_menu_state();
break;
}
+ case CURRENT_STATUS_SET_TIME_UNIT:
+ {
+ value = atoi(cmd);
+ __test_set_time_unit(value);
+ reset_menu_state();
+ break;
+ }
default:
break;
}