]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add external_video_source to media handle and expose switch_core_media_start_video_th...
authorSeven Du <dujinfang@gmail.com>
Wed, 12 Nov 2014 00:39:35 +0000 (08:39 +0800)
committerSeven Du <dujinfang@gmail.com>
Wed, 12 Nov 2014 00:44:20 +0000 (08:44 +0800)
src/include/switch_core_media.h
src/switch_core_media.c

index d5baac404a46e8fa3a8b2f4daf3ff83218a3fd2a..1915b742ae756b181f7831b5faac64d6e0313ffb 100644 (file)
@@ -146,6 +146,15 @@ typedef struct switch_core_media_params_s {
        switch_core_media_dtmf_t dtmf_type;
        switch_payload_t cng_pt;
 
+       /* a core_video_thread will be started automatically
+          when uses rtp based media,
+          external_video_source should be set to SWITCH_TRUE and
+          switch_core_media_start_video_thread()
+          should be explicitly called to start the video thread
+          if uses the media handle for non-rtp based media
+       */
+       switch_bool_t external_video_source;
+
 } switch_core_media_params_t;
 
 static inline const char *switch_media_type2str(switch_media_type_t type)
@@ -252,6 +261,7 @@ SWITCH_DECLARE(void) switch_core_media_deinit(void);
 SWITCH_DECLARE(void) switch_core_media_set_stats(switch_core_session_t *session);
 SWITCH_DECLARE(void) switch_core_session_wake_video_thread(switch_core_session_t *session);
 SWITCH_DECLARE(void) switch_core_session_clear_crypto(switch_core_session_t *session);
+SWITCH_DECLARE(switch_status_t) switch_core_media_start_video_thread(switch_core_session_t *session);
 
 SWITCH_DECLARE(switch_status_t) switch_core_session_get_payload_code(switch_core_session_t *session,
                                                                                                                                         switch_media_type_t type,
index b5a039830812819b4df8ed4d8e17254f6bda5b39..1c7c369474b86a9166a60c8f3e659bd310a23c37 100644 (file)
@@ -4375,7 +4375,10 @@ static switch_status_t start_video_thread(switch_core_session_t *session)
 
        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "%s Starting Video thread\n", switch_core_session_get_name(session));
 
-       switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt);
+       if (v_engine->rtp_session) {
+               switch_rtp_set_default_payload(v_engine->rtp_session, v_engine->cur_payload_map->agreed_pt);
+       }
+
        v_engine->mh.session = session;
        switch_threadattr_create(&thd_attr, pool);
        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
@@ -4388,7 +4391,10 @@ static switch_status_t start_video_thread(switch_core_session_t *session)
        return SWITCH_STATUS_SUCCESS;
 }
 
-
+SWITCH_DECLARE(switch_status_t) switch_core_media_start_video_thread(switch_core_session_t *session)
+{
+       return start_video_thread(session);
+}
 
 //?
 #define RA_PTR_LEN 512
@@ -4940,7 +4946,13 @@ SWITCH_DECLARE(void) switch_core_session_wake_video_thread(switch_core_session_t
 
        v_engine = &smh->engines[SWITCH_MEDIA_TYPE_VIDEO];
 
-       if (!v_engine->rtp_session) {
+       if ((!smh->mparams->external_video_source) && (!v_engine->rtp_session)) {
+               return;
+       }
+
+       if (!v_engine->mh.cond_mutex) {
+               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Channel %s has no cond?\n",
+                                                 switch_channel_get_name(session->channel));
                return;
        }