aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacki <jacki@thejackimonster.de>2024-08-15 17:06:23 +0200
committerJacki <jacki@thejackimonster.de>2024-08-15 17:06:23 +0200
commit9e5d0b2c06c0ee82f8643318e74ca9cda37b7d87 (patch)
treeab2bd2f85456e8a9e5045fc75f3fb65d9ec3d3fc
parentc28fa0b89f5ef3ec027ecdc9b1966ee0bfb2c647 (diff)
downloadmessenger-gtk-9e5d0b2c06c0ee82f8643318e74ca9cda37b7d87.tar.gz
messenger-gtk-9e5d0b2c06c0ee82f8643318e74ca9cda37b7d87.zip
Add fakesrc to add insert empty buffers into video stream
-rw-r--r--src/discourse.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/discourse.c b/src/discourse.c
index 7456c8e..46a8569 100644
--- a/src/discourse.c
+++ b/src/discourse.c
@@ -370,11 +370,13 @@ discourse_subscription_stream_message(MESSENGER_DiscourseSubscriptionInfo *info,
370 goto skip_buffer; 370 goto skip_buffer;
371 371
372 uint64_t timestamp = info->last_timestamp; 372 uint64_t timestamp = info->last_timestamp;
373 uint32_t payload_len = 0;
373 374
374 GstRTPBuffer rtp = GST_RTP_BUFFER_INIT; 375 GstRTPBuffer rtp = GST_RTP_BUFFER_INIT;
375 if (gst_rtp_buffer_map(buffer, GST_MAP_READ, &rtp)) 376 if (gst_rtp_buffer_map(buffer, GST_MAP_READ, &rtp))
376 { 377 {
377 const uint32_t rtp_timestamp = gst_rtp_buffer_get_timestamp(&rtp); 378 const uint32_t rtp_timestamp = gst_rtp_buffer_get_timestamp(&rtp);
379 payload_len = gst_rtp_buffer_get_payload_len(&rtp);
378 380
379 timestamp = gst_rtp_buffer_ext_timestamp(&timestamp, rtp_timestamp); 381 timestamp = gst_rtp_buffer_ext_timestamp(&timestamp, rtp_timestamp);
380 if (!timestamp) 382 if (!timestamp)
@@ -383,14 +385,17 @@ discourse_subscription_stream_message(MESSENGER_DiscourseSubscriptionInfo *info,
383 gst_rtp_buffer_unmap(&rtp); 385 gst_rtp_buffer_unmap(&rtp);
384 } 386 }
385 387
386 info->buffers = g_list_append(info->buffers, buffer); 388 if (payload_len)
389 info->buffers = g_list_append(info->buffers, buffer);
390
387 buffer = NULL; 391 buffer = NULL;
388 392
389 if ((info->last_timestamp == timestamp) || 393 if ((info->last_timestamp == timestamp) ||
390 ((!(info->last_timestamp)) && (!(info->position)))) 394 ((!(info->last_timestamp)) && (!(info->position))))
391 goto skip_buffer; 395 goto skip_buffer;
392 396
393 buffer = gst_buffer_new(); 397 if (info->buffers)
398 buffer = gst_buffer_new();
394 399
395 GList *buf = info->buffers; 400 GList *buf = info->buffers;
396 while (buf) 401 while (buf)
@@ -418,10 +423,13 @@ discourse_subscription_stream_message(MESSENGER_DiscourseSubscriptionInfo *info,
418 423
419 const uint64_t duration = timestamp - info->last_timestamp; 424 const uint64_t duration = timestamp - info->last_timestamp;
420 425
421 GST_BUFFER_TIMESTAMP(buffer) = gst_util_uint64_scale(info->position, GST_SECOND, clockrate); 426 if (buffer)
422 GST_BUFFER_DURATION(buffer) = gst_util_uint64_scale(duration, GST_SECOND, clockrate); 427 {
428 GST_BUFFER_TIMESTAMP(buffer) = gst_util_uint64_scale(info->position, GST_SECOND, clockrate);
429 GST_BUFFER_DURATION(buffer) = gst_util_uint64_scale(duration, GST_SECOND, clockrate);
423 430
424 g_signal_emit_by_name(appsrc, "push-buffer", buffer, &ret); 431 g_signal_emit_by_name(appsrc, "push-buffer", buffer, &ret);
432 }
425 433
426 if ((appsrc) && (!(info->position))) 434 if ((appsrc) && (!(info->position)))
427 gst_element_set_state(appsrc, GST_STATE_PLAYING); 435 gst_element_set_state(appsrc, GST_STATE_PLAYING);
@@ -588,7 +596,13 @@ _setup_video_gst_pipelines(MESSENGER_DiscourseInfo *info)
588 g_assert(info); 596 g_assert(info);
589 597
590 info->video_record_pipeline = gst_parse_launch( 598 info->video_record_pipeline = gst_parse_launch(
591 "pipewiresrc name=source ! video/x-raw,framerate={ [ 0/1, 30/1 ] } ! videoscale ! video/x-raw,width=1280,height=720 ! videoconvert ! video/x-raw,format=I420 ! x264enc bitrate=1000 speed-preset=fast bframes=0 key-int-max=30 tune=zerolatency byte-stream=true ! video/x-h264,profile=baseline ! rtph264pay aggregate-mode=zero-latency mtu=45000 ! capsfilter name=filter ! fdsink name=sink", 599 "pipewiresrc name=source ! video/x-raw,framerate={ [ 0/1, 30/1 ] } ! videoscale ! "
600 "video/x-raw,width=1280,height=720 ! videoconvert ! video/x-raw,format=I420 ! "
601 "x264enc bitrate=1000 speed-preset=fast bframes=0 key-int-max=30 tune=zerolatency byte-stream=true ! "
602 "video/x-h264,profile=baseline ! rtph264pay aggregate-mode=zero-latency mtu=45000 ! "
603 "tee ! queue ! capsfilter name=filter ! fdsink name=sink "
604 "fakesrc num-buffers=-1 sizetype=empty filltype=zero ! "
605 "video/x-h264,stream-format=avc,alignment=au ! rtph264pay ! mux.",
592 NULL 606 NULL
593 ); 607 );
594 608