Commit 1b4b50ef authored by Benjamin Berg's avatar Benjamin Berg
Browse files

wfd: Decrease keyframe count if possible

Many devices can request IDR frames if they need them. In that case, we
don't need to insert as many IDR frames into the stream, so increase the
GOP size for the encoder.
parent c79ea002
......@@ -218,7 +218,7 @@ wfd_client_configure_client_media (GstRTSPClient * client,
self->media = WFD_MEDIA (media);
element = gst_rtsp_media_get_element (media);
wfd_configure_media_element (GST_BIN (element), self->params->selected_codec, self->params->selected_resolution);
wfd_configure_media_element (GST_BIN (element), self->params);
res = GST_RTSP_CLIENT_CLASS (wfd_client_parent_class)->configure_client_media (client, media, stream, ctx);
......@@ -292,14 +292,22 @@ wfd_media_factory_create_pipeline (GstRTSPMediaFactory *factory, GstRTSPMedia *m
wfd_configure_media_element (GstBin *bin, WfdVideoCodec *codec, WfdResolution *resolution)
wfd_configure_media_element (GstBin *bin, WfdParams *params)
g_autoptr(GstCaps) caps = NULL;
g_autoptr(GstElement) sizefilter = NULL;
g_autoptr(GstElement) encoder = NULL;
g_autoptr(GstElement) selector_interlace = NULL;
g_autoptr(GstPad) selector_interlace_pad = NULL;
WfdVideoCodec *codec = params->selected_codec;
WfdResolution *resolution = params->selected_resolution;
WfdH264Encoder encoder_impl;
guint gop_size = resolution->refresh_rate;
/* Decrease the number of keyframes if the device is able to request
* IDRs by itself. */
if (params->idr_request_capability)
gop_size = 10 * resolution->refresh_rate;
caps = gst_caps_new_simple ("video/x-raw",
"framerate", GST_TYPE_FRACTION, resolution->refresh_rate, 1,
......@@ -324,6 +332,7 @@ wfd_configure_media_element (GstBin *bin, WfdVideoCodec *codec, WfdResolution *r
"enable-frame-skip", codec->frame_skipping_allowed,
"max-bitrate", wfd_video_codec_get_max_bitrate_kbit (codec) * 1024,
"bitrate", wfd_video_codec_get_max_bitrate_kbit (codec) * 1024,
"gop-size", gop_size,
......@@ -337,7 +346,7 @@ wfd_configure_media_element (GstBin *bin, WfdVideoCodec *codec, WfdResolution *r
/* "pass", "cbr", */
"b-adapt", FALSE,
"bframes", 0,
"key-int-max", resolution->refresh_rate,
"key-int-max", gop_size,
"interlaced", resolution->interlaced,
"bitrate", wfd_video_codec_get_max_bitrate_kbit (codec),
"max-rc-lookahead", 0,
#pragma once
#include <gst/rtsp-server/rtsp-media-factory.h>
#include "wfd-video-codec.h"
#include "wfd-params.h"
......@@ -13,7 +13,6 @@ WfdMediaFactory * wfd_media_factory_new (void);
/* Just because it is convenient to have next to the pipeline creation code */
void wfd_configure_media_element (GstBin *bin,
WfdVideoCodec *codec,
WfdResolution *resolution);
WfdParams *params);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment