]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-7514: make vlc endpoint works with originate in addition to bridge
authorSeven Du <dujinfang@gmail.com>
Tue, 3 Feb 2015 15:02:11 +0000 (23:02 +0800)
committerMichael Jerris <mike@jerris.com>
Thu, 28 May 2015 17:46:57 +0000 (12:46 -0500)
src/mod/formats/mod_vlc/mod_vlc.c
src/switch_core_media.c

index 1810fd50305fe62d65a2f6f29cbc662f51c6b413..c6e619aa094cd171f16e6570735ba38637a897b9 100644 (file)
@@ -880,6 +880,14 @@ static switch_status_t setup_tech_pvt(switch_core_session_t *osession, switch_co
 
        if (osession) {
                switch_core_session_get_read_impl(osession, &tech_pvt->read_impl);
+       } else {
+               /* hard coded values, could also be set according to var_event if we want to support HD audio or stereo */
+               tech_pvt->read_impl.microseconds_per_packet = 20000;
+               tech_pvt->read_impl.samples_per_packet = 8000;
+               tech_pvt->read_impl.actual_samples_per_second = tech_pvt->read_impl.samples_per_packet;
+               tech_pvt->read_impl.number_of_channels = 1;
+               tech_pvt->read_impl.iananame = "L16";
+               tech_pvt->read_impl.decoded_bytes_per_packet = 320 * tech_pvt->read_impl.number_of_channels;
        }
 
        tech_pvt->session = session;
@@ -1115,8 +1123,8 @@ static switch_call_cause_t vlc_outgoing_channel(switch_core_session_t *session,
        }
 
        if (!codec_str) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No video codec?\n");
-               goto fail;
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No video codec set, default to VP8\n");
+               codec_str = "VP8";
        }
 
        if (switch_core_codec_init(&tech_pvt->video_codec,
@@ -1155,11 +1163,6 @@ static switch_call_cause_t vlc_outgoing_channel(switch_core_session_t *session,
        switch_core_session_start_video_thread(*new_session);
        switch_channel_set_state(channel, CS_INIT);
 
-       if (switch_core_session_thread_launch(*new_session) != SWITCH_STATUS_SUCCESS) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't start session thread.\n");
-               goto fail;
-       }
-
        switch_channel_mark_answered(channel);
 
        // start play
@@ -1209,14 +1212,12 @@ static switch_status_t vlc_read_frame(switch_core_session_t *session, switch_fra
        tech_pvt = switch_core_session_get_private(session);
        assert(tech_pvt != NULL);
 
-       switch_yield(20000);
+       switch_yield(tech_pvt->read_impl.microseconds_per_packet);
 
        audio_datalen = tech_pvt->read_impl.decoded_bytes_per_packet;
 
-       // goto cng;
-
        context = tech_pvt->context;
-       assert(context);
+       switch_assert(context);
 
        vlc_status = libvlc_media_get_state(context->m);
 
@@ -1230,7 +1231,6 @@ static switch_status_t vlc_read_frame(switch_core_session_t *session, switch_fra
 
        if (switch_buffer_inuse(context->audio_buffer) >= audio_datalen) {
                tech_pvt->read_frame.data = tech_pvt->audio_data;
-               //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%d %d\n", (int)switch_buffer_inuse(context->audio_buffer), (int)audio_datalen);
                switch_buffer_read(context->audio_buffer, tech_pvt->read_frame.data, audio_datalen);
                tech_pvt->read_frame.datalen = audio_datalen;
                tech_pvt->read_frame.buflen = audio_datalen;
index 2050bf2fb01cea9b6745e507e42bf86e7fb1f3af..c51021e2d26bce2d061e2f26cf60c529920276ee 100644 (file)
@@ -9985,7 +9985,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_video_frame(switch_core
                }
        }
 
-       if (switch_channel_test_flag(session->channel, CF_VIDEO_DECODED_READ)) {
+       if (switch_channel_test_flag(session->channel, CF_VIDEO_DECODED_READ) && (*frame)->img == NULL) {
                switch_status_t decode_status;
 
                (*frame)->img = NULL;