diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 10ec60bdd6415c1f6c83a5ebd4f5240298752dea..74d67075c535e2df1e50eb4bd608f1254b0ee0ba 100644 --- a/coreapi/private_functions.h +++ b/coreapi/private_functions.h @@ -69,6 +69,7 @@ LinphonePrivate::SalCallOp *linphone_call_get_op(const LinphoneCall *call); LINPHONE_PUBLIC LinphoneProxyConfig *linphone_call_get_dest_proxy(const LinphoneCall *call); LINPHONE_PUBLIC MediaStream * linphone_call_get_stream(LinphoneCall *call, LinphoneStreamType type); +LINPHONE_PUBLIC VideoStream * linphone_core_get_preview_stream(LinphoneCore *call); // FIXME: Remove this declaration, use LINPHONE_PUBLIC as ugly workaround, already defined in tester_utils.h LINPHONE_PUBLIC IceSession *linphone_call_get_ice_session(const LinphoneCall *call); diff --git a/coreapi/tester_utils.h b/coreapi/tester_utils.h index aa39fc0ec7ca74263b3d7e317069ef20e9e9f196..361205bb3b57ca286f46483ae15c5790dade85fd 100644 --- a/coreapi/tester_utils.h +++ b/coreapi/tester_utils.h @@ -90,6 +90,7 @@ LINPHONE_PUBLIC LinphoneProxyConfigAddressComparisonResult linphone_proxy_config LINPHONE_PUBLIC LinphoneProxyConfigAddressComparisonResult linphone_proxy_config_address_equal(const LinphoneAddress *a, const LinphoneAddress *b); LINPHONE_PUBLIC MediaStream * linphone_call_get_stream(LinphoneCall *call, LinphoneStreamType type); +LINPHONE_PUBLIC VideoStream * linphone_core_get_preview_stream(LinphoneCore *call); LINPHONE_PUBLIC bool_t linphone_call_get_all_muted(const LinphoneCall *call); LINPHONE_PUBLIC LinphoneProxyConfig * linphone_call_get_dest_proxy(const LinphoneCall *call); LINPHONE_PUBLIC unsigned int _linphone_call_get_nb_audio_starts (const LinphoneCall *call); diff --git a/include/linphone/utils/general.h b/include/linphone/utils/general.h index 46c4e0fca3051f0650530dc757ec3ec9f36042fe..562fc9f289ed0222eb2c21afcbaa361a35054372 100644 --- a/include/linphone/utils/general.h +++ b/include/linphone/utils/general.h @@ -79,7 +79,7 @@ LINPHONE_BEGIN_NAMESPACE // Debug. // ----------------------------------------------------------------------------- -void lAssert (const char *condition, const char *file, int line); +LINPHONE_PUBLIC void lAssert (const char *condition, const char *file, int line); #ifdef DEBUG #define L_ASSERT(CONDITION) ((CONDITION) ? static_cast<void>(0) : LinphonePrivate::lAssert(#CONDITION, __FILE__, __LINE__)) diff --git a/src/c-wrapper/api/c-core.cpp b/src/c-wrapper/api/c-core.cpp index afa1d8ecf4d8a76c9e50ff7027b2661e7c59fc0d..9b6945a8cf0d6c02b172e0ad1740bf9ac48a4ca3 100644 --- a/src/c-wrapper/api/c-core.cpp +++ b/src/c-wrapper/api/c-core.cpp @@ -224,3 +224,7 @@ const LinphoneAudioDevice* linphone_core_get_default_output_audio_device(const L } return NULL; } + +VideoStream * linphone_core_get_preview_stream(LinphoneCore *lc) { + return lc->previewstream; +} diff --git a/src/c-wrapper/internal/c-tools.h b/src/c-wrapper/internal/c-tools.h index 30936f47c077c374b65cc380ffc2d3714e8d3387..2f328633cc6747a5d1d03a20499d21e1e99e60a4 100644 --- a/src/c-wrapper/internal/c-tools.h +++ b/src/c-wrapper/internal/c-tools.h @@ -151,8 +151,8 @@ private: // --------------------------------------------------------------------------- #ifdef DEBUG - static void setName (belle_sip_object_t *cObject, const BaseObject *cppObject); - static void setName (belle_sip_object_t *cObject, const ClonableObject *cppObject); + LINPHONE_PUBLIC static void setName (belle_sip_object_t *cObject, const BaseObject *cppObject); + LINPHONE_PUBLIC static void setName (belle_sip_object_t *cObject, const ClonableObject *cppObject); #endif // --------------------------------------------------------------------------- diff --git a/tester/video_tester.c b/tester/video_tester.c index 0ea626b36da74a67d9b022e03543bb495cfa2ec8..d1f2cd1cd0b637cf775a934de5844d77437be82a 100644 --- a/tester/video_tester.c +++ b/tester/video_tester.c @@ -23,9 +23,10 @@ #include "liblinphone_tester.h" #include "tester_utils.h" #include "linphone/lpconfig.h" - #include <mediastreamer2/msqrcodereader.h> + + static void enable_disable_camera_after_camera_switches(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -61,6 +62,33 @@ static void enable_disable_camera_after_camera_switches(void) { linphone_core_manager_destroy(pauline); } +static void camera_switches_while_only_preview(void) { + LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); + const char *camId = "Mire: Mire (synthetic moving picture)"; + float fps = 0.0f; + MSWebCam *cam = ms_web_cam_manager_get_cam(ms_factory_get_web_cam_manager(linphone_core_get_ms_factory(marie->lc)),camId ); + + if (cam == NULL) { + MSWebCamDesc *desc = ms_mire_webcam_desc_get(); + if (desc) { + cam=ms_web_cam_new(desc); + ms_web_cam_manager_add_cam(ms_factory_get_web_cam_manager(linphone_core_get_ms_factory(marie->lc)), cam); + } + } + linphone_core_set_video_device(marie->lc, camId); + linphone_core_iterate(marie->lc); + linphone_core_enable_video_preview(marie->lc, TRUE); + linphone_core_iterate(marie->lc); // Let time to the core to set new values + VideoStream *vs = (VideoStream *)linphone_core_get_preview_stream(marie->lc); + if(BC_ASSERT_PTR_NOT_NULL(vs) && BC_ASSERT_PTR_NOT_NULL(vs->source) ){ + ms_filter_call_method(vs->source, MS_FILTER_SET_FPS,(void *)&fps); //Simulate camera deficiency + BC_ASSERT_TRUE(vs->cam == cam); + wait_for_until(marie->lc, NULL, NULL, 0, 6000); + BC_ASSERT_TRUE(vs->cam != cam); + } + linphone_core_manager_destroy(marie); +} + typedef struct struct_qrcode_callback_data { int qrcode_found; char *text; @@ -148,7 +176,8 @@ static void decode_qrcode_from_zone(void) { test_t video_tests[] = { TEST_NO_TAG("Enable/disable camera after camera switches", enable_disable_camera_after_camera_switches), TEST_ONE_TAG("Decode QRCode from image", decode_qrcode_from_image, "QRCode"), - TEST_ONE_TAG("Decode QRCode from zone", decode_qrcode_from_zone, "QRCode") + TEST_ONE_TAG("Decode QRCode from zone", decode_qrcode_from_zone, "QRCode"), + TEST_NO_TAG("Fallback camera while preview is only enabled", camera_switches_while_only_preview) }; test_suite_t video_test_suite = {