diff options
author | Benny Prijono <bennylp@teluu.com> | 2011-09-20 10:07:55 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2011-09-20 10:07:55 +0000 |
commit | be8d37186b16150716f752883ae6857a0161db40 (patch) | |
tree | 269fb1f2c16f90e539cf9534163dde56594bcb89 /pjmedia | |
parent | b9aa69da263759ce63593adae3327b8de25cd388 (diff) |
Related to preview (re #1340): handle problems with starting or stopping preview during a call
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3758 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r-- | pjmedia/include/pjmedia-videodev/videodev.h | 42 | ||||
-rw-r--r-- | pjmedia/include/pjmedia-videodev/videodev_imp.h | 3 | ||||
-rw-r--r-- | pjmedia/include/pjmedia/vid_port.h | 9 | ||||
-rw-r--r-- | pjmedia/src/pjmedia-videodev/videodev.c | 14 | ||||
-rw-r--r-- | pjmedia/src/pjmedia/vid_port.c | 5 |
5 files changed, 70 insertions, 3 deletions
diff --git a/pjmedia/include/pjmedia-videodev/videodev.h b/pjmedia/include/pjmedia-videodev/videodev.h index 30a9750b..0c3d4c82 100644 --- a/pjmedia/include/pjmedia-videodev/videodev.h +++ b/pjmedia/include/pjmedia-videodev/videodev.h @@ -220,7 +220,13 @@ typedef struct pjmedia_vid_dev_info */ pjmedia_dir dir; - /** Specify whether the device supports callback */ + /** + * Specify whether the device supports callback. Devices that implement + * "active interface" will actively call the callbacks to give or ask for + * video frames. If the device doesn't support callback, application + * must actively request or give video frames from/to the device by using + * pjmedia_vid_dev_stream_get_frame()/pjmedia_vid_dev_stream_put_frame(). + */ pj_bool_t has_callback; /** Device capabilities, as bitmask combination of #pjmedia_vid_dev_cap */ @@ -641,6 +647,16 @@ PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_start( pjmedia_vid_dev_stream *strm); /** + * Query whether the stream has been started. + * + * @param strm The video stream + * + * @return PJ_TRUE if the video stream has been started. + */ +PJ_DECL(pj_bool_t) pjmedia_vid_dev_stream_is_running(pjmedia_vid_dev_stream *strm); + + +/** * Get the event publisher object for the video stream. Caller typically use * the returned object to subscribe or unsubscribe events from the video * stream. @@ -652,11 +668,33 @@ PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_start( PJ_DECL(pjmedia_event_publisher*) pjmedia_vid_dev_stream_get_event_publisher(pjmedia_vid_dev_stream *strm); -/* Get/put frame API for passive stream */ + +/** + * Request one frame from the stream. Application needs to call this function + * periodically only if the stream doesn't support "active interface", i.e. + * the pjmedia_vid_dev_info.has_callback member is PJ_FALSE. + * + * @param strm The video stream. + * @param frame The video frame to be filled by the device. + * + * @return PJ_SUCCESS on successful operation or the appropriate + * error code. + */ PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_frame( pjmedia_vid_dev_stream *strm, pjmedia_frame *frame); +/** + * Put one frame to the stream. Application needs to call this function + * periodically only if the stream doesn't support "active interface", i.e. + * the pjmedia_vid_dev_info.has_callback member is PJ_FALSE. + * + * @param strm The video stream. + * @param frame The video frame to put to the device. + * + * @return PJ_SUCCESS on successful operation or the appropriate + * error code. + */ PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_put_frame( pjmedia_vid_dev_stream *strm, const pjmedia_frame *frame); diff --git a/pjmedia/include/pjmedia-videodev/videodev_imp.h b/pjmedia/include/pjmedia-videodev/videodev_imp.h index 90dcc580..8ddfd968 100644 --- a/pjmedia/include/pjmedia-videodev/videodev_imp.h +++ b/pjmedia/include/pjmedia-videodev/videodev_imp.h @@ -181,6 +181,9 @@ struct pjmedia_vid_dev_stream struct { /** Driver index */ unsigned drv_idx; + + /** Has it been started? */ + pj_bool_t is_running; } sys; /** Operations */ diff --git a/pjmedia/include/pjmedia/vid_port.h b/pjmedia/include/pjmedia/vid_port.h index b7fa5666..66c31c84 100644 --- a/pjmedia/include/pjmedia/vid_port.h +++ b/pjmedia/include/pjmedia/vid_port.h @@ -213,6 +213,15 @@ pjmedia_vid_port_get_connected_port(pjmedia_vid_port *vid_port); PJ_DECL(pj_status_t) pjmedia_vid_port_start(pjmedia_vid_port *vid_port); /** + * Query whether the video port has been started. + * + * @param vid_port The video port. + * + * @return PJ_TRUE if the video port has been started. + */ +PJ_DECL(pj_bool_t) pjmedia_vid_port_is_running(pjmedia_vid_port *vid_port); + +/** * Stop the video port. * * @param vid_port The video port. diff --git a/pjmedia/src/pjmedia-videodev/videodev.c b/pjmedia/src/pjmedia-videodev/videodev.c index a88e91c4..f2523d79 100644 --- a/pjmedia/src/pjmedia-videodev/videodev.c +++ b/pjmedia/src/pjmedia-videodev/videodev.c @@ -781,7 +781,17 @@ pjmedia_vid_dev_stream_get_event_publisher(pjmedia_vid_dev_stream *strm) /* API: Start the stream. */ PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_start(pjmedia_vid_dev_stream *strm) { - return strm->op->start(strm); + pj_status_t status = strm->op->start(strm); + if (status == PJ_SUCCESS) + strm->sys.is_running = PJ_TRUE; + return status; +} + +/* API: has it been started? */ +PJ_DEF(pj_bool_t) +pjmedia_vid_dev_stream_is_running(pjmedia_vid_dev_stream *strm) +{ + return strm->sys.is_running; } PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_get_frame( @@ -803,6 +813,7 @@ PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_put_frame( /* API: Stop the stream. */ PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_stop(pjmedia_vid_dev_stream *strm) { + strm->sys.is_running = PJ_FALSE; return strm->op->stop(strm); } @@ -810,6 +821,7 @@ PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_stop(pjmedia_vid_dev_stream *strm) PJ_DEF(pj_status_t) pjmedia_vid_dev_stream_destroy( pjmedia_vid_dev_stream *strm) { + strm->sys.is_running = PJ_FALSE; return strm->op->destroy(strm); } diff --git a/pjmedia/src/pjmedia/vid_port.c b/pjmedia/src/pjmedia/vid_port.c index 56694cd7..fa5c2da6 100644 --- a/pjmedia/src/pjmedia/vid_port.c +++ b/pjmedia/src/pjmedia/vid_port.c @@ -479,6 +479,11 @@ on_error: return status; } +PJ_DEF(pj_bool_t) pjmedia_vid_port_is_running(pjmedia_vid_port *vp) +{ + return pjmedia_vid_dev_stream_is_running(vp->strm); +} + PJ_DEF(pj_status_t) pjmedia_vid_port_stop(pjmedia_vid_port *vp) { pj_status_t status; |