mirror of
https://github.com/albfan/miraclecast.git
synced 2025-02-12 14:51:54 +00:00
miracle-dispd, gstencoder: enable audio supporting
Change-Id: I4d72782516ffff487010cd94cc47ec68133ff257
This commit is contained in:
parent
0011c8eb40
commit
aadfeec79c
5 changed files with 65 additions and 37 deletions
|
@ -212,8 +212,8 @@ internal class GstEncoder : DispdEncoder, GLib.Object
|
|||
configs.contains(DispdEncoderConfig.Y)
|
||||
? configs.get(DispdEncoderConfig.Y).get_uint32()
|
||||
: 0,
|
||||
width - 1,
|
||||
height - 1,
|
||||
configs.get(DispdEncoderConfig.X).get_uint32() + width - 1,
|
||||
configs.get(DispdEncoderConfig.Y).get_uint32() + height - 1,
|
||||
framerate,
|
||||
gen_scaler_n_converter_desc(width, height),
|
||||
gen_encoder_desc(framerate),
|
||||
|
@ -252,6 +252,26 @@ internal class GstEncoder : DispdEncoder, GLib.Object
|
|||
: 16385);
|
||||
}
|
||||
|
||||
if(configs.contains(DispdEncoderConfig.AUDIO_TYPE)) {
|
||||
desc.append_printf("pulsesrc " +
|
||||
"do-timestamp=true " +
|
||||
"client-name=miraclecast " +
|
||||
"device=\"%s\" " +
|
||||
"! avenc_aac " +
|
||||
"! audio/mpeg, " +
|
||||
"channels=2, " +
|
||||
"rate=48000 " +
|
||||
// "base-profile=lc " +
|
||||
"! queue " +
|
||||
"max-size-buffers=0 " +
|
||||
"max-size-bytes=0 " +
|
||||
"max-size-time=0 " +
|
||||
"! muxer. ",
|
||||
configs.contains(DispdEncoderConfig.AUDIO_DEV)
|
||||
? configs.get(DispdEncoderConfig.AUDIO_DEV).get_string()
|
||||
: "");
|
||||
}
|
||||
|
||||
info("final pipeline description: %s", desc.str);
|
||||
|
||||
this.configs = configs;
|
||||
|
@ -270,34 +290,6 @@ internal class GstEncoder : DispdEncoder, GLib.Object
|
|||
pipeline.set_state(Gst.State.READY);
|
||||
}
|
||||
|
||||
// if(*os->audio_dev) {
|
||||
// for(tmp = pipeline_desc; *tmp; ++tmp);
|
||||
// *tmp ++ = "pulsesrc";
|
||||
// *tmp ++ = "do-timestamp=true";
|
||||
// *tmp ++ = "client-name=miraclecast";
|
||||
// *tmp ++ = "device=";
|
||||
// *tmp ++ = quote_str(os->audio_dev, audio_dev, sizeof(audio_dev));
|
||||
// *tmp ++ = "!";
|
||||
// *tmp ++ = "voaacenc";
|
||||
// *tmp ++ = "mark-granule=true";
|
||||
// *tmp ++ = "hard-resync=true";
|
||||
// *tmp ++ = "tolerance=40";
|
||||
// *tmp ++ = "!";
|
||||
// *tmp ++ = "audio/mpeg,";
|
||||
// *tmp ++ = "rate=48000,";
|
||||
// *tmp ++ = "channels=2,";
|
||||
// *tmp ++ = "stream-format=adts,";
|
||||
// *tmp ++ = "base-profile=lc";
|
||||
// *tmp ++ = "!";
|
||||
// *tmp ++ = "queue";
|
||||
// *tmp ++ = "max-size-buffers=0";
|
||||
// *tmp ++ = "max-size-bytes=0";
|
||||
// *tmp ++ = "max-size-time=0";
|
||||
// *tmp ++ = "!";
|
||||
// *tmp ++ = "muxer.";
|
||||
// *tmp ++ = NULL;
|
||||
// }
|
||||
|
||||
public void start() throws DispdEncoderError
|
||||
{
|
||||
check_configs();
|
||||
|
|
|
@ -532,14 +532,16 @@ static int dispd_dbus_sink_start_session(sd_bus_message *m,
|
|||
return log_ERR(r);
|
||||
}
|
||||
|
||||
r = dispd_session_set_audio_type(sess, DISPD_AUDIO_SERVER_TYPE_PULSE_AUDIO);
|
||||
if(0 > r) {
|
||||
return log_ERR(r);
|
||||
}
|
||||
if(*audio_dev) {
|
||||
r = dispd_session_set_audio_type(sess, DISPD_AUDIO_SERVER_TYPE_PULSE_AUDIO);
|
||||
if(0 > r) {
|
||||
return log_ERR(r);
|
||||
}
|
||||
|
||||
r = dispd_session_set_audio_dev_name(sess, audio_dev);
|
||||
if(0 > r) {
|
||||
return log_ERR(r);
|
||||
r = dispd_session_set_audio_dev_name(sess, audio_dev);
|
||||
if(0 > r) {
|
||||
return log_ERR(r);
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_bus_query_sender_creds(m, SD_BUS_CREDS_PID, &creds);
|
||||
|
|
|
@ -840,6 +840,24 @@ int dispd_encoder_configure(struct dispd_encoder *e, struct dispd_session *s)
|
|||
}
|
||||
}
|
||||
|
||||
if(dispd_session_has_audio(s) && dispd_session_get_audio_dev_name(s)) {
|
||||
r = config_append(call,
|
||||
WFD_ENCODER_CONFIG_AUDIO_TYPE,
|
||||
"u",
|
||||
dispd_session_get_audio_type(s));
|
||||
if(0 > r) {
|
||||
return log_ERR(r);
|
||||
}
|
||||
|
||||
r = config_append(call,
|
||||
WFD_ENCODER_CONFIG_AUDIO_DEV,
|
||||
"s",
|
||||
dispd_session_get_audio_dev_name(s));
|
||||
if(0 > r) {
|
||||
return log_ERR(r);
|
||||
}
|
||||
}
|
||||
|
||||
r = sd_bus_message_close_container(call);
|
||||
if(0 > r) {
|
||||
return log_ERR(r);
|
||||
|
|
|
@ -810,6 +810,13 @@ enum dispd_display_server_type dispd_session_get_disp_type(struct dispd_session
|
|||
return s->disp_type;
|
||||
}
|
||||
|
||||
bool dispd_session_has_disp(struct dispd_session *s)
|
||||
{
|
||||
assert_retv(s, false);
|
||||
|
||||
return DISPD_DISPLAY_SERVER_TYPE_UNKNOWN != s->disp_type;
|
||||
}
|
||||
|
||||
int dispd_session_set_disp_type(struct dispd_session *s, enum dispd_display_server_type disp_type)
|
||||
{
|
||||
assert_ret(s);
|
||||
|
@ -926,6 +933,13 @@ enum dispd_audio_server_type dispd_session_get_audio_type(struct dispd_session *
|
|||
return s->audio_type;
|
||||
}
|
||||
|
||||
bool dispd_session_has_audio(struct dispd_session *s)
|
||||
{
|
||||
assert_retv(s, false);
|
||||
|
||||
return DISPD_AUDIO_SERVER_TYPE_UNKNOWN != s->audio_type;
|
||||
}
|
||||
|
||||
int dispd_session_set_audio_type(struct dispd_session *s, enum dispd_audio_server_type audio_type)
|
||||
{
|
||||
assert_ret(s);
|
||||
|
|
|
@ -113,6 +113,7 @@ enum dispd_session_dir dispd_session_get_dir(struct dispd_session *s);
|
|||
struct dispd_sink * dispd_out_session_get_sink(struct dispd_session *s);
|
||||
|
||||
enum dispd_display_server_type dispd_session_get_disp_type(struct dispd_session *s);
|
||||
bool dispd_session_has_disp(struct dispd_session *s);
|
||||
int dispd_session_set_disp_type(struct dispd_session *s, enum dispd_display_server_type);
|
||||
const char * dispd_session_get_disp_name(struct dispd_session *s);
|
||||
int dispd_session_set_disp_name(struct dispd_session *s, const char *disp_name);
|
||||
|
@ -123,6 +124,7 @@ int dispd_session_set_disp_auth(struct dispd_session *s, const char *disp_auth);
|
|||
const struct dispd_rectangle * dispd_session_get_disp_dimension(struct dispd_session *s);
|
||||
int dispd_session_set_disp_dimension(struct dispd_session *s, const struct dispd_rectangle *rect);
|
||||
enum dispd_audio_server_type dispd_session_get_audio_type(struct dispd_session *s);
|
||||
bool dispd_session_has_audio(struct dispd_session *s);
|
||||
int dispd_session_set_audio_type(struct dispd_session *s, enum dispd_audio_server_type audio_type);
|
||||
const char * dispd_session_get_audio_dev_name(struct dispd_session *s);
|
||||
int dispd_session_set_audio_dev_name(struct dispd_session *s, const char *audio_dev_name);
|
||||
|
|
Loading…
Reference in a new issue