mirror of
https://github.com/morgan9e/UxPlay
synced 2026-04-14 00:04:13 +09:00
introduce -vsync, -async options
This commit is contained in:
@@ -33,7 +33,7 @@ extern "C" {
|
||||
#include "../lib/logger.h"
|
||||
|
||||
bool gstreamer_init();
|
||||
void audio_renderer_init(logger_t *logger, const char* audiosink, const bool *audio_sync);
|
||||
void audio_renderer_init(logger_t *logger, const char* audiosink, const bool *audio_sync, const bool *video_sync);
|
||||
void audio_renderer_start(unsigned char* compression_type);
|
||||
void audio_renderer_stop();
|
||||
void audio_renderer_render_buffer(unsigned char* data, int *data_len, unsigned short *seqnum, uint64_t *ntp_time);
|
||||
|
||||
@@ -85,7 +85,7 @@ bool gstreamer_init(){
|
||||
return (bool) check_plugins ();
|
||||
}
|
||||
|
||||
void audio_renderer_init(logger_t *render_logger, const char* audiosink, const bool* audio_sync) {
|
||||
void audio_renderer_init(logger_t *render_logger, const char* audiosink, const bool* audio_sync, const bool* video_sync) {
|
||||
GError *error = NULL;
|
||||
GstCaps *caps = NULL;
|
||||
GstClock *clock = gst_system_clock_obtain();
|
||||
@@ -124,7 +124,11 @@ void audio_renderer_init(logger_t *render_logger, const char* audiosink, const b
|
||||
}
|
||||
break;
|
||||
default:
|
||||
g_string_append (launch, " sync=false");
|
||||
if (*video_sync) {
|
||||
g_string_append (launch, " sync=true");
|
||||
} else {
|
||||
g_string_append (launch, " sync=false");
|
||||
}
|
||||
break;
|
||||
}
|
||||
renderer_type[i]->pipeline = gst_parse_launch(launch->str, &error);
|
||||
@@ -211,6 +215,7 @@ void audio_renderer_render_buffer(unsigned char* data, int *data_len, unsigned s
|
||||
GstBuffer *buffer;
|
||||
bool valid;
|
||||
GstClockTime pts = (GstClockTime) *ntp_time ; /* now in nsecs */
|
||||
//GstClockTimeDiff latency = GST_CLOCK_DIFF(gst_element_get_current_clock_time (renderer->appsrc), pts);
|
||||
if (pts >= gst_audio_pipeline_base_time) {
|
||||
pts -= gst_audio_pipeline_base_time;
|
||||
} else {
|
||||
@@ -229,6 +234,7 @@ void audio_renderer_render_buffer(unsigned char* data, int *data_len, unsigned s
|
||||
|
||||
buffer = gst_buffer_new_allocate(NULL, *data_len, NULL);
|
||||
g_assert(buffer != NULL);
|
||||
//g_print("audio latency %8.6f\n", (double) latency / SECOND_IN_NSECS);
|
||||
GST_BUFFER_PTS(buffer) = pts;
|
||||
gst_buffer_fill(buffer, 0, data, *data_len);
|
||||
switch (renderer->ct){
|
||||
@@ -288,4 +294,3 @@ void audio_renderer_destroy() {
|
||||
free(renderer_type[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ typedef enum videoflip_e {
|
||||
typedef struct video_renderer_s video_renderer_t;
|
||||
|
||||
void video_renderer_init (logger_t *logger, const char *server_name, videoflip_t videoflip[2], const char *parser,
|
||||
const char *decoder, const char *converter, const char *videosink, const bool *fullscreen);
|
||||
const char *decoder, const char *converter, const char *videosink, const bool *fullscreen,
|
||||
const bool *video_sync);
|
||||
void video_renderer_start ();
|
||||
void video_renderer_stop ();
|
||||
void video_renderer_render_buffer (unsigned char* data, int *data_len, int *nal_count, uint64_t *ntp_time);
|
||||
|
||||
@@ -128,7 +128,8 @@ void video_renderer_size(float *f_width_source, float *f_height_source, float *f
|
||||
}
|
||||
|
||||
void video_renderer_init(logger_t *render_logger, const char *server_name, videoflip_t videoflip[2], const char *parser,
|
||||
const char *decoder, const char *converter, const char *videosink, const bool *initial_fullscreen) {
|
||||
const char *decoder, const char *converter, const char *videosink, const bool *initial_fullscreen,
|
||||
const bool *video_sync) {
|
||||
GError *error = NULL;
|
||||
GstCaps *caps = NULL;
|
||||
GstClock *clock = gst_system_clock_obtain();
|
||||
@@ -156,7 +157,12 @@ void video_renderer_init(logger_t *render_logger, const char *server_name, vide
|
||||
g_string_append(launch, " ! ");
|
||||
append_videoflip(launch, &videoflip[0], &videoflip[1]);
|
||||
g_string_append(launch, videosink);
|
||||
g_string_append(launch, " name=video_sink sync=false");
|
||||
g_string_append(launch, " name=video_sink");
|
||||
if (*video_sync) {
|
||||
g_string_append(launch, " sync=true");
|
||||
} else {
|
||||
g_string_append(launch, " sync=false");
|
||||
}
|
||||
logger_log(logger, LOGGER_DEBUG, "GStreamer video pipeline will be:\n\"%s\"", launch->str);
|
||||
renderer->pipeline = gst_parse_launch(launch->str, &error);
|
||||
if (error) {
|
||||
@@ -226,6 +232,7 @@ void video_renderer_start() {
|
||||
void video_renderer_render_buffer(unsigned char* data, int *data_len, int *nal_count, uint64_t *ntp_time) {
|
||||
GstBuffer *buffer;
|
||||
GstClockTime pts = (GstClockTime) *ntp_time; /*now in nsecs */
|
||||
//GstClockTimeDiff latency = GST_CLOCK_DIFF(gst_element_get_current_clock_time (renderer->appsrc), pts);
|
||||
if (pts >= gst_video_pipeline_base_time) {
|
||||
pts -= gst_video_pipeline_base_time;
|
||||
} else {
|
||||
@@ -247,6 +254,7 @@ void video_renderer_render_buffer(unsigned char* data, int *data_len, int *nal_c
|
||||
}
|
||||
buffer = gst_buffer_new_allocate(NULL, *data_len, NULL);
|
||||
g_assert(buffer != NULL);
|
||||
//g_print("video latency %8.6f\n", (double) latency / SECOND_IN_NSECS);
|
||||
GST_BUFFER_PTS(buffer) = pts;
|
||||
gst_buffer_fill(buffer, 0, data, *data_len);
|
||||
gst_app_src_push_buffer (GST_APP_SRC(renderer->appsrc), buffer);
|
||||
|
||||
Reference in New Issue
Block a user