Changeset 3758
- Timestamp:
- Sep 20, 2011 10:07:55 AM (13 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia-videodev/videodev.h
r3756 r3758 221 221 pjmedia_dir dir; 222 222 223 /** Specify whether the device supports callback */ 223 /** 224 * Specify whether the device supports callback. Devices that implement 225 * "active interface" will actively call the callbacks to give or ask for 226 * video frames. If the device doesn't support callback, application 227 * must actively request or give video frames from/to the device by using 228 * pjmedia_vid_dev_stream_get_frame()/pjmedia_vid_dev_stream_put_frame(). 229 */ 224 230 pj_bool_t has_callback; 225 231 … … 642 648 643 649 /** 650 * Query whether the stream has been started. 651 * 652 * @param strm The video stream 653 * 654 * @return PJ_TRUE if the video stream has been started. 655 */ 656 PJ_DECL(pj_bool_t) pjmedia_vid_dev_stream_is_running(pjmedia_vid_dev_stream *strm); 657 658 659 /** 644 660 * Get the event publisher object for the video stream. Caller typically use 645 661 * the returned object to subscribe or unsubscribe events from the video … … 653 669 pjmedia_vid_dev_stream_get_event_publisher(pjmedia_vid_dev_stream *strm); 654 670 655 /* Get/put frame API for passive stream */ 671 672 /** 673 * Request one frame from the stream. Application needs to call this function 674 * periodically only if the stream doesn't support "active interface", i.e. 675 * the pjmedia_vid_dev_info.has_callback member is PJ_FALSE. 676 * 677 * @param strm The video stream. 678 * @param frame The video frame to be filled by the device. 679 * 680 * @return PJ_SUCCESS on successful operation or the appropriate 681 * error code. 682 */ 656 683 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_frame( 657 684 pjmedia_vid_dev_stream *strm, 658 685 pjmedia_frame *frame); 659 686 687 /** 688 * Put one frame to the stream. Application needs to call this function 689 * periodically only if the stream doesn't support "active interface", i.e. 690 * the pjmedia_vid_dev_info.has_callback member is PJ_FALSE. 691 * 692 * @param strm The video stream. 693 * @param frame The video frame to put to the device. 694 * 695 * @return PJ_SUCCESS on successful operation or the appropriate 696 * error code. 697 */ 660 698 PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_put_frame( 661 699 pjmedia_vid_dev_stream *strm, -
pjproject/trunk/pjmedia/include/pjmedia-videodev/videodev_imp.h
r3715 r3758 182 182 /** Driver index */ 183 183 unsigned drv_idx; 184 185 /** Has it been started? */ 186 pj_bool_t is_running; 184 187 } sys; 185 188 -
pjproject/trunk/pjmedia/include/pjmedia/vid_port.h
r3715 r3758 214 214 215 215 /** 216 * Query whether the video port has been started. 217 * 218 * @param vid_port The video port. 219 * 220 * @return PJ_TRUE if the video port has been started. 221 */ 222 PJ_DECL(pj_bool_t) pjmedia_vid_port_is_running(pjmedia_vid_port *vid_port); 223 224 /** 216 225 * Stop the video port. 217 226 * -
pjproject/trunk/pjmedia/src/pjmedia-videodev/videodev.c
r3756 r3758 782 782 PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_start(pjmedia_vid_dev_stream *strm) 783 783 { 784 return strm->op->start(strm); 784 pj_status_t status = strm->op->start(strm); 785 if (status == PJ_SUCCESS) 786 strm->sys.is_running = PJ_TRUE; 787 return status; 788 } 789 790 /* API: has it been started? */ 791 PJ_DEF(pj_bool_t) 792 pjmedia_vid_dev_stream_is_running(pjmedia_vid_dev_stream *strm) 793 { 794 return strm->sys.is_running; 785 795 } 786 796 … … 804 814 PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_stop(pjmedia_vid_dev_stream *strm) 805 815 { 816 strm->sys.is_running = PJ_FALSE; 806 817 return strm->op->stop(strm); 807 818 } … … 811 822 pjmedia_vid_dev_stream *strm) 812 823 { 824 strm->sys.is_running = PJ_FALSE; 813 825 return strm->op->destroy(strm); 814 826 } -
pjproject/trunk/pjmedia/src/pjmedia/vid_port.c
r3723 r3758 478 478 pjmedia_vid_port_stop(vp); 479 479 return status; 480 } 481 482 PJ_DEF(pj_bool_t) pjmedia_vid_port_is_running(pjmedia_vid_port *vp) 483 { 484 return pjmedia_vid_dev_stream_is_running(vp->strm); 480 485 } 481 486 -
pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h
r3756 r3758 325 325 pjmedia_port *tee; /**< Video tee */ 326 326 pjmedia_vid_dev_index preview_cap_id;/**< Capture dev id */ 327 pj_bool_t preview_running;/**< Preview is started*/ 327 328 pj_bool_t is_native; /**< Preview is by dev */ 328 329 } pjsua_vid_win; -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c
r3756 r3758 324 324 */ 325 325 326 /* 327 * Get the preview window handle associated with the capture device, if any. 328 */ 329 PJ_DEF(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id) 326 static pjsua_vid_win_id vid_preview_get_win(pjmedia_vid_dev_index id, 327 pj_bool_t running_only) 330 328 { 331 329 pjsua_vid_win_id wid = PJSUA_INVALID_ID; … … 348 346 } 349 347 } 348 349 if (wid != PJSUA_INVALID_ID && running_only) { 350 pjsua_vid_win *w = &pjsua_var.win[wid]; 351 wid = w->preview_running ? wid : PJSUA_INVALID_ID; 352 } 353 350 354 PJSUA_UNLOCK(); 351 355 352 356 return wid; 357 } 358 359 /* 360 * NOTE: internal function don't use this!!! Use vid_preview_get_win() 361 * instead. This is because this function will only return window ID 362 * if preview is currently running. 363 */ 364 PJ_DEF(pjsua_vid_win_id) pjsua_vid_preview_get_win(pjmedia_vid_dev_index id) 365 { 366 return vid_preview_get_win(id, PJ_TRUE); 353 367 } 354 368 … … 394 408 /* If type is preview, check if it exists already */ 395 409 if (type == PJSUA_WND_TYPE_PREVIEW) { 396 wid = pjsua_vid_preview_get_win(cap_id);410 wid = vid_preview_get_win(cap_id, PJ_FALSE); 397 411 if (wid != PJSUA_INVALID_ID) { 398 412 /* Yes, it exists */ … … 421 435 /* Done */ 422 436 *id = wid; 423 PJ_LOG(4,(THIS_FILE, "Window already exist: %d", wid));424 437 pj_log_pop_indent(); 425 return PJ_SUCCESS; 438 439 return status; 426 440 } 427 441 } … … 826 840 } 827 841 828 wid = pjsua_vid_preview_get_win(call_med->strm.v.cap_dev); 842 /* Note: calling pjsua_vid_preview_get_win() even though 843 * create_vid_win() will automatically create the window 844 * if it doesn't exist, because create_vid_win() will modify 845 * existing window SHOW/HIDE value. 846 */ 847 wid = vid_preview_get_win(call_med->strm.v.cap_dev, PJ_FALSE); 829 848 if (wid == PJSUA_INVALID_ID) { 830 849 /* Create preview video window */ … … 1043 1062 1044 1063 w = &pjsua_var.win[wid]; 1064 if (w->preview_running) { 1065 PJSUA_UNLOCK(); 1066 pj_log_pop_indent(); 1067 return PJ_SUCCESS; 1068 } 1045 1069 1046 1070 /* Start renderer, unless it's native preview */ 1047 if (!w->is_native) { 1071 if (w->is_native && !pjmedia_vid_port_is_running(w->vp_cap)) { 1072 pjmedia_vid_dev_stream *cap_dev; 1073 pj_bool_t enabled = PJ_TRUE; 1074 1075 cap_dev = pjmedia_vid_port_get_stream(w->vp_cap); 1076 status = pjmedia_vid_dev_stream_set_cap( 1077 cap_dev, PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW, 1078 &enabled); 1079 if (status != PJ_SUCCESS) { 1080 PJ_PERROR(1,(THIS_FILE, status, 1081 "Error activating native preview, falling back " 1082 "to software preview..")); 1083 w->is_native = PJ_FALSE; 1084 } 1085 } 1086 1087 if (!w->is_native && !pjmedia_vid_port_is_running(w->vp_rend)) { 1048 1088 status = pjmedia_vid_port_start(w->vp_rend); 1049 1089 if (status != PJ_SUCCESS) { … … 1055 1095 1056 1096 /* Start capturer */ 1057 status = pjmedia_vid_port_start(w->vp_cap); 1058 if (status != PJ_SUCCESS) { 1059 PJSUA_UNLOCK(); 1060 pj_log_pop_indent(); 1061 return status; 1097 if (!pjmedia_vid_port_is_running(w->vp_cap)) { 1098 status = pjmedia_vid_port_start(w->vp_cap); 1099 if (status != PJ_SUCCESS) { 1100 PJSUA_UNLOCK(); 1101 pj_log_pop_indent(); 1102 return status; 1103 } 1062 1104 } 1063 1105 1064 1106 inc_vid_win(wid); 1107 w->preview_running = PJ_TRUE; 1065 1108 1066 1109 PJSUA_UNLOCK(); … … 1075 1118 { 1076 1119 pjsua_vid_win_id wid = PJSUA_INVALID_ID; 1077 1078 PJ_LOG(4,(THIS_FILE, "Stopping preview for cap_dev=%d", id)); 1079 pj_log_push_indent(); 1120 pjsua_vid_win *w; 1121 pj_status_t status; 1080 1122 1081 1123 PJSUA_LOCK(); … … 1087 1129 } 1088 1130 1089 dec_vid_win(wid); 1131 PJ_LOG(4,(THIS_FILE, "Stopping preview for cap_dev=%d", id)); 1132 pj_log_push_indent(); 1133 1134 w = &pjsua_var.win[wid]; 1135 if (w->preview_running) { 1136 if (w->is_native) { 1137 pjmedia_vid_dev_stream *cap_dev; 1138 pj_bool_t enabled = PJ_FALSE; 1139 1140 cap_dev = pjmedia_vid_port_get_stream(w->vp_cap); 1141 status = pjmedia_vid_dev_stream_set_cap( 1142 cap_dev, PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW, 1143 &enabled); 1144 } else { 1145 status = pjmedia_vid_port_stop(w->vp_rend); 1146 } 1147 1148 if (status != PJ_SUCCESS) { 1149 PJ_PERROR(1,(THIS_FILE, status, "Error stopping %spreview", 1150 (w->is_native ? "native " : ""))); 1151 PJSUA_UNLOCK(); 1152 pj_log_pop_indent(); 1153 return status; 1154 } 1155 1156 dec_vid_win(wid); 1157 w->preview_running = PJ_FALSE; 1158 } 1090 1159 1091 1160 PJSUA_UNLOCK(); … … 1674 1743 /* = Attach stream port to the new capture device = */ 1675 1744 1676 new_wid = pjsua_vid_preview_get_win(cap_dev); 1745 /* Note: calling pjsua_vid_preview_get_win() even though 1746 * create_vid_win() will automatically create the window 1747 * if it doesn't exist, because create_vid_win() will modify 1748 * existing window SHOW/HIDE value. 1749 */ 1750 new_wid = vid_preview_get_win(cap_dev, PJ_FALSE); 1677 1751 if (new_wid == PJSUA_INVALID_ID) { 1678 1752 /* Create preview video window */
Note: See TracChangeset
for help on using the changeset viewer.