videodev.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef __PJMEDIA_VIDEO_DEV_H__
  19. #define __PJMEDIA_VIDEO_DEV_H__
  20. /**
  21. * @file videodev.h
  22. * @brief Video device API.
  23. */
  24. #include <pjmedia-videodev/config.h>
  25. #include <pjmedia-videodev/errno.h>
  26. #include <pjmedia/frame.h>
  27. #include <pjmedia/format.h>
  28. #include <pj/pool.h>
  29. PJ_BEGIN_DECL
  30. /**
  31. * @defgroup video_device_reference Video Device API Reference
  32. * @ingroup video_device_api
  33. * @brief API Reference
  34. * @{
  35. */
  36. /**
  37. * Type for device index.
  38. */
  39. typedef pj_int32_t pjmedia_vid_dev_index;
  40. /**
  41. * Enumeration of window handle type.
  42. */
  43. typedef enum pjmedia_vid_dev_hwnd_type
  44. {
  45. /**
  46. * Type none.
  47. */
  48. PJMEDIA_VID_DEV_HWND_TYPE_NONE,
  49. /**
  50. * Native window handle on Windows.
  51. */
  52. PJMEDIA_VID_DEV_HWND_TYPE_WINDOWS,
  53. /**
  54. * Native view on Cocoa Mac.
  55. */
  56. PJMEDIA_VID_DEV_HWND_TYPE_COCOA,
  57. /**
  58. * Native view on iOS.
  59. */
  60. PJMEDIA_VID_DEV_HWND_TYPE_IOS,
  61. /**
  62. * Native window handle on Android.
  63. */
  64. PJMEDIA_VID_DEV_HWND_TYPE_ANDROID
  65. } pjmedia_vid_dev_hwnd_type;
  66. /**
  67. * Type for window handle.
  68. */
  69. typedef struct pjmedia_vid_dev_hwnd
  70. {
  71. /**
  72. * The window handle type.
  73. */
  74. pjmedia_vid_dev_hwnd_type type;
  75. /**
  76. * The window handle.
  77. */
  78. union
  79. {
  80. struct {
  81. void *hwnd; /**< HWND */
  82. } win;
  83. struct {
  84. void *window; /**< Window */
  85. void *display; /**< Display */
  86. } x11;
  87. struct {
  88. void *window; /**< Window */
  89. } cocoa;
  90. struct {
  91. void *window; /**< Window */
  92. } ios;
  93. struct {
  94. void *window; /**< Native window */
  95. } android;
  96. void *window;
  97. } info;
  98. } pjmedia_vid_dev_hwnd;
  99. /**
  100. * Parameter for switching device with PJMEDIA_VID_DEV_CAP_SWITCH capability.
  101. * Initialize this with pjmedia_vid_dev_switch_param_default()
  102. */
  103. typedef struct pjmedia_vid_dev_switch_param
  104. {
  105. /**
  106. * Target device ID to switch to. Once the switching is successful, the
  107. * video stream will use this device and the old device will be closed.
  108. */
  109. pjmedia_vid_dev_index target_id;
  110. } pjmedia_vid_dev_switch_param;
  111. /**
  112. * Enumeration of window flags.
  113. */
  114. typedef enum pjmedia_vid_dev_wnd_flag
  115. {
  116. /**
  117. * Window with border.
  118. */
  119. PJMEDIA_VID_DEV_WND_BORDER = 1,
  120. /**
  121. * Window can be resized.
  122. */
  123. PJMEDIA_VID_DEV_WND_RESIZABLE = 2
  124. } pjmedia_vid_dev_wnd_flag;
  125. /**
  126. * Device index constants.
  127. */
  128. enum pjmedia_vid_dev_std_index
  129. {
  130. /**
  131. * Constant to denote default capture device
  132. */
  133. PJMEDIA_VID_DEFAULT_CAPTURE_DEV = -1,
  134. /**
  135. * Constant to denote default render device
  136. */
  137. PJMEDIA_VID_DEFAULT_RENDER_DEV = -2,
  138. /**
  139. * Constant to denote invalid device index.
  140. */
  141. PJMEDIA_VID_INVALID_DEV = -3
  142. };
  143. /**
  144. * Enumeration of window fullscreen flags.
  145. */
  146. typedef enum pjmedia_vid_dev_fullscreen_flag
  147. {
  148. /**
  149. * Windowed or disable fullscreen.
  150. */
  151. PJMEDIA_VID_DEV_WINDOWED = 0,
  152. /**
  153. * Fullscreen enabled, video mode may be changed.
  154. */
  155. PJMEDIA_VID_DEV_FULLSCREEN = 1,
  156. /**
  157. * Fullscreen enabled by resizing video frame to match to the desktop,
  158. * video mode will not be changed.
  159. */
  160. PJMEDIA_VID_DEV_FULLSCREEN_DESKTOP = 2
  161. } pjmedia_vid_dev_fullscreen_flag;
  162. /**
  163. * This enumeration identifies various video device capabilities. These video
  164. * capabilities indicates what features are supported by the underlying
  165. * video device implementation.
  166. *
  167. * Applications get these capabilities in the #pjmedia_vid_dev_info structure.
  168. *
  169. * Application can also set the specific features/capabilities when opening
  170. * the video stream by setting the \a flags member of #pjmedia_vid_dev_param
  171. * structure.
  172. *
  173. * Once video stream is running, application can also retrieve or set some
  174. * specific video capability, by using #pjmedia_vid_dev_stream_get_cap() and
  175. * #pjmedia_vid_dev_stream_set_cap() and specifying the desired capability. The
  176. * value of the capability is specified as pointer, and application needs to
  177. * supply the pointer with the correct value, according to the documentation
  178. * of each of the capability.
  179. */
  180. typedef enum pjmedia_vid_dev_cap
  181. {
  182. /**
  183. * Support for video formats. The value of this capability
  184. * is represented by #pjmedia_format structure.
  185. */
  186. PJMEDIA_VID_DEV_CAP_FORMAT = 1,
  187. /**
  188. * Support for video input scaling
  189. */
  190. PJMEDIA_VID_DEV_CAP_INPUT_SCALE = 2,
  191. /**
  192. * Support for returning the native window handle of the video window.
  193. * For renderer, this means the window handle of the renderer window,
  194. * while for capture, this means the window handle of the native preview,
  195. * only if the device supports PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW
  196. * capability.
  197. *
  198. * The value of this capability is pointer to pjmedia_vid_dev_hwnd
  199. * structure.
  200. */
  201. PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW = 4,
  202. /**
  203. * Support for resizing video output. This capability SHOULD be
  204. * implemented by renderer, to alter the video output dimension on the fly.
  205. * Value is pjmedia_rect_size.
  206. */
  207. PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE = 8,
  208. /**
  209. * Support for setting the video window's position.
  210. * Value is pjmedia_coord specifying the window's new coordinate.
  211. */
  212. PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION = 16,
  213. /**
  214. * Support for setting the video output's visibility.
  215. * The value of this capability is a pj_bool_t containing boolean
  216. * PJ_TRUE or PJ_FALSE.
  217. */
  218. PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE = 32,
  219. /**
  220. * Support for native preview capability in capture devices. Value is
  221. * pj_bool_t. With native preview, capture device can be instructed to
  222. * show or hide a preview window showing video directly from the camera
  223. * by setting this capability to PJ_TRUE or PJ_FALSE. Once the preview
  224. * is started, application may use PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW
  225. * capability to query the video window.
  226. *
  227. * The value of this capability is a pj_bool_t containing boolean
  228. * PJ_TRUE or PJ_FALSE.
  229. */
  230. PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW = 64,
  231. /**
  232. * Support for changing video orientation. For a renderer device,
  233. * changing video orientation in will potentially affect the size of
  234. * render window, i.e: width and height swap. For a capture device,
  235. * the video will be rotated but the size of the video frame
  236. * will stay the same, so the video may be resized or stretched.
  237. *
  238. * The value of this capability is pjmedia_orient.
  239. */
  240. PJMEDIA_VID_DEV_CAP_ORIENTATION = 128,
  241. /**
  242. * Support for fast switching to another device. A video stream with this
  243. * capability allows replacing of its underlying device with another
  244. * device, saving the user from opening a new video stream and gets a much
  245. * faster and smoother switching action.
  246. *
  247. * Note that even when this capability is supported by a device, it may
  248. * not be able to switch to arbitrary device. Application must always
  249. * check the return value of the operation to verify that switching has
  250. * occurred.
  251. *
  252. * This capability is currently write-only (i.e. set-only).
  253. *
  254. * The value of this capability is pointer to pjmedia_vid_dev_switch_param
  255. * structure.
  256. */
  257. PJMEDIA_VID_DEV_CAP_SWITCH = 256,
  258. /**
  259. * Support for setting the output video window's flags.
  260. * The value of this capability is a bitmask combination of
  261. * #pjmedia_vid_dev_wnd_flag.
  262. */
  263. PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS = 512,
  264. /**
  265. * Support for setting the output video window full screen.
  266. */
  267. PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN = 1024,
  268. /**
  269. * End of standard capability
  270. */
  271. PJMEDIA_VID_DEV_CAP_MAX = 16384
  272. } pjmedia_vid_dev_cap;
  273. /**
  274. * Device information structure returned by #pjmedia_vid_dev_get_info().
  275. */
  276. typedef struct pjmedia_vid_dev_info
  277. {
  278. /** The device ID */
  279. pjmedia_vid_dev_index id;
  280. /** The device name */
  281. char name[64];
  282. /** The underlying driver name */
  283. char driver[32];
  284. /**
  285. * The supported direction of the video device, i.e. whether it supports
  286. * capture only, render only, or both.
  287. */
  288. pjmedia_dir dir;
  289. /**
  290. * Specify whether the device supports callback. Devices that implement
  291. * "active interface" will actively call the callbacks to give or ask for
  292. * video frames. If the device doesn't support callback, application
  293. * must actively request or give video frames from/to the device by using
  294. * pjmedia_vid_dev_stream_get_frame()/pjmedia_vid_dev_stream_put_frame().
  295. */
  296. pj_bool_t has_callback;
  297. /** Device capabilities, as bitmask combination of #pjmedia_vid_dev_cap */
  298. unsigned caps;
  299. /** Number of video formats supported by this device */
  300. unsigned fmt_cnt;
  301. /**
  302. * Array of supported video formats. Some fields in each supported video
  303. * format may be set to zero or of "unknown" value, to indicate that the
  304. * value is unknown or should be ignored. When these value are not set
  305. * to zero, it indicates that the exact format combination is being used.
  306. */
  307. pjmedia_format fmt[PJMEDIA_VID_DEV_INFO_FMT_CNT];
  308. } pjmedia_vid_dev_info;
  309. /** Forward declaration for pjmedia_vid_dev_stream */
  310. typedef struct pjmedia_vid_dev_stream pjmedia_vid_dev_stream;
  311. typedef struct pjmedia_vid_dev_cb
  312. {
  313. /**
  314. * This callback is called by capturer stream when it has captured the
  315. * whole packet worth of video samples.
  316. *
  317. * @param stream The video stream.
  318. * @param user_data User data associated with the stream.
  319. * @param frame Captured frame.
  320. *
  321. * @return Returning non-PJ_SUCCESS will cause the video
  322. * stream to stop
  323. */
  324. pj_status_t (*capture_cb)(pjmedia_vid_dev_stream *stream,
  325. void *user_data,
  326. pjmedia_frame *frame);
  327. /**
  328. * This callback is called by renderer stream when it needs additional
  329. * data to be rendered by the device. Application must fill in the whole
  330. * of output buffer with video samples.
  331. *
  332. * The frame argument contains the following values:
  333. * - timestamp Rendering timestamp, in samples.
  334. * - buf Buffer to be filled out by application.
  335. * - size The size requested in bytes, which will be equal
  336. * to the size of one whole packet.
  337. *
  338. * @param stream The video stream.
  339. * @param user_data User data associated with the stream.
  340. * @param frame Video frame, which buffer is to be filled in by
  341. * the application.
  342. *
  343. * @return Returning non-PJ_SUCCESS will cause the video
  344. * stream to stop
  345. */
  346. pj_status_t (*render_cb)(pjmedia_vid_dev_stream *stream,
  347. void *user_data,
  348. pjmedia_frame *frame);
  349. } pjmedia_vid_dev_cb;
  350. /**
  351. * This structure specifies the parameters to open the video stream.
  352. */
  353. typedef struct pjmedia_vid_dev_param
  354. {
  355. /**
  356. * The video direction. This setting is mandatory.
  357. */
  358. pjmedia_dir dir;
  359. /**
  360. * The video capture device ID. This setting is mandatory if the video
  361. * direction includes input/capture direction.
  362. */
  363. pjmedia_vid_dev_index cap_id;
  364. /**
  365. * The video render device ID. This setting is mandatory if the video
  366. * direction includes output/render direction.
  367. */
  368. pjmedia_vid_dev_index rend_id;
  369. /**
  370. * Video clock rate. This setting is mandatory if the video
  371. * direction includes input/capture direction
  372. */
  373. unsigned clock_rate;
  374. /**
  375. * Video frame rate. This setting is mandatory if the video
  376. * direction includes input/capture direction
  377. */
  378. // pjmedia_ratio frame_rate;
  379. /**
  380. * This flags specifies which of the optional settings are valid in this
  381. * structure. The flags is bitmask combination of pjmedia_vid_dev_cap.
  382. */
  383. unsigned flags;
  384. /**
  385. * Set the video format. This setting is mandatory.
  386. */
  387. pjmedia_format fmt;
  388. /**
  389. * Window for the renderer to display the video. This setting is optional,
  390. * and will only be used if PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW is set in
  391. * the flags.
  392. */
  393. pjmedia_vid_dev_hwnd window;
  394. /**
  395. * Video display size. This setting is optional, and will only be used
  396. * if PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE is set in the flags.
  397. */
  398. pjmedia_rect_size disp_size;
  399. /**
  400. * Video window position. This setting is optional, and will only be used
  401. * if PJMEDIA_VID_DEV_CAP_OUTPUT_POSITION is set in the flags.
  402. */
  403. pjmedia_coord window_pos;
  404. /**
  405. * Video window's visibility. This setting is optional, and will only be
  406. * used if PJMEDIA_VID_DEV_CAP_OUTPUT_HIDE is set in the flags.
  407. */
  408. pj_bool_t window_hide;
  409. /**
  410. * Enable built-in preview. This setting is optional and is only used
  411. * if PJMEDIA_VID_DEV_CAP_INPUT_PREVIEW capability is supported and
  412. * set in the flags.
  413. */
  414. pj_bool_t native_preview;
  415. /**
  416. * Video orientation. This setting is optional and is only used if
  417. * PJMEDIA_VID_DEV_CAP_ORIENTATION capability is supported and is
  418. * set in the flags.
  419. */
  420. pjmedia_orient orient;
  421. /**
  422. * Video window flags. This setting is optional, and will only be used
  423. * if PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS is set in the flags.
  424. */
  425. unsigned window_flags;
  426. /**
  427. * Video window's fullscreen status. This setting is optional, and will
  428. * only be used if PJMEDIA_VID_DEV_CAP_OUTPUT_FULLSCREEN is set in the
  429. * flags.
  430. */
  431. pjmedia_vid_dev_fullscreen_flag window_fullscreen;
  432. } pjmedia_vid_dev_param;
  433. /** Forward declaration for video device factory */
  434. typedef struct pjmedia_vid_dev_factory pjmedia_vid_dev_factory;
  435. /* typedef for factory creation function */
  436. typedef pjmedia_vid_dev_factory*
  437. (*pjmedia_vid_dev_factory_create_func_ptr)(pj_pool_factory*);
  438. /* Video driver structure */
  439. typedef struct pjmedia_vid_driver
  440. {
  441. pjmedia_vid_dev_factory_create_func_ptr create; /* Creation function */
  442. pjmedia_vid_dev_factory *f; /* Factory instance */
  443. char name[32]; /* Driver name */
  444. unsigned dev_cnt; /* Number of devices */
  445. unsigned start_idx; /* Start index in global list */
  446. int cap_dev_idx; /* Default capture device. */
  447. int rend_dev_idx; /* Default render device */
  448. } pjmedia_vid_driver;
  449. /* The video device subsystem */
  450. typedef struct pjmedia_vid_subsys
  451. {
  452. unsigned init_count; /* How many times init() is called */
  453. pj_pool_factory *pf; /* The pool factory. */
  454. unsigned drv_cnt; /* Number of drivers. */
  455. pjmedia_vid_driver drv[PJMEDIA_VID_DEV_MAX_DRIVERS];/* Array of drivers.*/
  456. unsigned dev_cnt; /* Total number of devices. */
  457. pj_uint32_t dev_list[PJMEDIA_VID_DEV_MAX_DEVS];/* Array of devIDs*/
  458. } pjmedia_vid_subsys;
  459. /**
  460. * Get the video subsystem.
  461. *
  462. * @return The video subsystem.
  463. */
  464. PJ_DECL(pjmedia_vid_subsys*) pjmedia_get_vid_subsys(void);
  465. /**
  466. * Initialize the video driver.
  467. *
  468. * @param drv_idx The index of the video driver.
  469. * @param refresh Specify non-zero to refresh the video driver.
  470. *
  471. * @return PJ_SUCCESS on successful operation or the appropriate
  472. * error code.
  473. */
  474. PJ_DECL(pj_status_t) pjmedia_vid_driver_init(unsigned drv_idx,
  475. pj_bool_t refresh);
  476. /**
  477. * Deinitialize the video driver.
  478. *
  479. * @param drv_idx The index of the video driver.
  480. */
  481. PJ_DECL(void) pjmedia_vid_driver_deinit(unsigned drv_idx);
  482. /**
  483. * Initialize pjmedia_vid_dev_switch_param.
  484. *
  485. * @param p Parameter to be initialized.
  486. */
  487. PJ_INLINE(void)
  488. pjmedia_vid_dev_switch_param_default(pjmedia_vid_dev_switch_param *p)
  489. {
  490. pj_bzero(p, sizeof(*p));
  491. p->target_id = PJMEDIA_VID_INVALID_DEV;
  492. }
  493. /**
  494. * Get string info for the specified capability.
  495. *
  496. * @param cap The capability ID.
  497. * @param p_desc Optional pointer which will be filled with longer
  498. * description about the capability.
  499. *
  500. * @return Capability name.
  501. */
  502. PJ_DECL(const char*) pjmedia_vid_dev_cap_name(pjmedia_vid_dev_cap cap,
  503. const char **p_desc);
  504. /**
  505. * Set a capability field value in #pjmedia_vid_dev_param structure. This will
  506. * also set the flags field for the specified capability in the structure.
  507. *
  508. * @param param The structure.
  509. * @param cap The video capability which value is to be set.
  510. * @param pval Pointer to value. Please see the type of value to
  511. * be supplied in the pjmedia_vid_dev_cap documentation.
  512. *
  513. * @return PJ_SUCCESS on successful operation or the appropriate
  514. * error code.
  515. */
  516. PJ_DECL(pj_status_t)
  517. pjmedia_vid_dev_param_set_cap(pjmedia_vid_dev_param *param,
  518. pjmedia_vid_dev_cap cap,
  519. const void *pval);
  520. /**
  521. * Get a capability field value from #pjmedia_vid_dev_param structure. This
  522. * function will return PJMEDIA_EVID_INVCAP error if the flag for that
  523. * capability is not set in the flags field in the structure.
  524. *
  525. * @param param The structure.
  526. * @param cap The video capability which value is to be retrieved.
  527. * @param pval Pointer to value. Please see the type of value to
  528. * be supplied in the pjmedia_vid_dev_cap documentation.
  529. *
  530. * @return PJ_SUCCESS on successful operation or the appropriate
  531. * error code.
  532. */
  533. PJ_DECL(pj_status_t)
  534. pjmedia_vid_dev_param_get_cap(const pjmedia_vid_dev_param *param,
  535. pjmedia_vid_dev_cap cap,
  536. void *pval);
  537. /**
  538. * Refresh the list of video devices installed in the system. This function
  539. * will only refresh the list of videoo device so all active video streams will
  540. * be unaffected. After refreshing the device list, application MUST make sure
  541. * to update all index references to video devices (i.e. all variables of type
  542. * pjmedia_vid_dev_index) before calling any function that accepts video device
  543. * index as its parameter.
  544. *
  545. * @return PJ_SUCCESS on successful operation or the appropriate
  546. * error code.
  547. */
  548. PJ_DECL(pj_status_t) pjmedia_vid_dev_refresh(void);
  549. /**
  550. * Get the number of video devices installed in the system.
  551. *
  552. * @return The number of video devices installed in the system.
  553. */
  554. PJ_DECL(unsigned) pjmedia_vid_dev_count(void);
  555. /**
  556. * Get device information.
  557. *
  558. * @param id The video device ID.
  559. * @param info The device information which will be filled in by this
  560. * function once it returns successfully.
  561. *
  562. * @return PJ_SUCCESS on successful operation or the appropriate
  563. * error code.
  564. */
  565. PJ_DECL(pj_status_t) pjmedia_vid_dev_get_info(pjmedia_vid_dev_index id,
  566. pjmedia_vid_dev_info *info);
  567. /**
  568. * Lookup device index based on the driver and device name.
  569. *
  570. * @param drv_name The driver name.
  571. * @param dev_name The device name.
  572. * @param id Pointer to store the returned device ID.
  573. *
  574. * @return PJ_SUCCESS if the device can be found.
  575. */
  576. PJ_DECL(pj_status_t) pjmedia_vid_dev_lookup(const char *drv_name,
  577. const char *dev_name,
  578. pjmedia_vid_dev_index *id);
  579. /**
  580. * Initialize the video device parameters with default values for the
  581. * specified device.
  582. *
  583. * @param pool The pool.
  584. * @param id The video device ID.
  585. * @param param The video device parameters which will be initialized
  586. * by this function once it returns successfully.
  587. *
  588. * @return PJ_SUCCESS on successful operation or the appropriate
  589. * error code.
  590. */
  591. PJ_DECL(pj_status_t)
  592. pjmedia_vid_dev_default_param(pj_pool_t *pool,
  593. pjmedia_vid_dev_index id,
  594. pjmedia_vid_dev_param *param);
  595. /**
  596. * Open video stream object using the specified parameters. If stream is
  597. * created successfully, this function will return PJ_SUCCESS and the
  598. * stream pointer will be returned in the p_strm argument.
  599. *
  600. * The opened stream may have been opened with different size and fps
  601. * than the requested values in the \a param argument. Application should
  602. * check the actual size and fps that the stream was opened with by inspecting
  603. * the values in the \a param argument and see if they have changed. Also
  604. * if the device ID in the \a param specifies default device, it may be
  605. * replaced with the actual device ID upon return.
  606. *
  607. * @param param On input, it specifies the video device parameters
  608. * to be used for the stream. On output, this will be
  609. * set to the actual video device parameters used to
  610. * open the stream.
  611. * @param cb Pointer to structure containing video stream
  612. * callbacks.
  613. * @param user_data Arbitrary user data, which will be given back in the
  614. * callbacks.
  615. * @param p_strm Pointer to receive the video stream.
  616. *
  617. * @return PJ_SUCCESS on successful operation or the appropriate
  618. * error code.
  619. */
  620. PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_create(
  621. pjmedia_vid_dev_param *param,
  622. const pjmedia_vid_dev_cb *cb,
  623. void *user_data,
  624. pjmedia_vid_dev_stream **p_strm);
  625. /**
  626. * Get the running parameters for the specified video stream.
  627. *
  628. * @param strm The video stream.
  629. * @param param Video stream parameters to be filled in by this
  630. * function once it returns successfully.
  631. *
  632. * @return PJ_SUCCESS on successful operation or the appropriate
  633. * error code.
  634. */
  635. PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_param(
  636. pjmedia_vid_dev_stream *strm,
  637. pjmedia_vid_dev_param *param);
  638. /**
  639. * Get the value of a specific capability of the video stream.
  640. *
  641. * @param strm The video stream.
  642. * @param cap The video capability which value is to be retrieved.
  643. * @param value Pointer to value to be filled in by this function
  644. * once it returns successfully. Please see the type
  645. * of value to be supplied in the pjmedia_vid_dev_cap
  646. * documentation.
  647. *
  648. * @return PJ_SUCCESS on successful operation or the appropriate
  649. * error code.
  650. */
  651. PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_cap(
  652. pjmedia_vid_dev_stream *strm,
  653. pjmedia_vid_dev_cap cap,
  654. void *value);
  655. /**
  656. * Set the value of a specific capability of the video stream.
  657. *
  658. * @param strm The video stream.
  659. * @param cap The video capability which value is to be set.
  660. * @param value Pointer to value. Please see the type of value to
  661. * be supplied in the pjmedia_vid_dev_cap documentation.
  662. *
  663. * @return PJ_SUCCESS on successful operation or the appropriate
  664. * error code.
  665. */
  666. PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_set_cap(
  667. pjmedia_vid_dev_stream *strm,
  668. pjmedia_vid_dev_cap cap,
  669. const void *value);
  670. /**
  671. * Start the stream.
  672. *
  673. * @param strm The video stream.
  674. *
  675. * @return PJ_SUCCESS on successful operation or the appropriate
  676. * error code.
  677. */
  678. PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_start(
  679. pjmedia_vid_dev_stream *strm);
  680. /**
  681. * Query whether the stream has been started.
  682. *
  683. * @param strm The video stream
  684. *
  685. * @return PJ_TRUE if the video stream has been started.
  686. */
  687. PJ_DECL(pj_bool_t) pjmedia_vid_dev_stream_is_running(pjmedia_vid_dev_stream *strm);
  688. /**
  689. * Request one frame from the stream. Application needs to call this function
  690. * periodically only if the stream doesn't support "active interface", i.e.
  691. * the pjmedia_vid_dev_info.has_callback member is PJ_FALSE.
  692. *
  693. * @param strm The video stream.
  694. * @param frame The video frame to be filled by the device.
  695. *
  696. * @return PJ_SUCCESS on successful operation or the appropriate
  697. * error code.
  698. */
  699. PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_get_frame(
  700. pjmedia_vid_dev_stream *strm,
  701. pjmedia_frame *frame);
  702. /**
  703. * Put one frame to the stream. Application needs to call this function
  704. * periodically only if the stream doesn't support "active interface", i.e.
  705. * the pjmedia_vid_dev_info.has_callback member is PJ_FALSE.
  706. *
  707. * @param strm The video stream.
  708. * @param frame The video frame to put to the device.
  709. *
  710. * @return PJ_SUCCESS on successful operation or the appropriate
  711. * error code.
  712. */
  713. PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_put_frame(
  714. pjmedia_vid_dev_stream *strm,
  715. const pjmedia_frame *frame);
  716. /**
  717. * Stop the stream.
  718. *
  719. * @param strm The video stream.
  720. *
  721. * @return PJ_SUCCESS on successful operation or the appropriate
  722. * error code.
  723. */
  724. PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_stop(
  725. pjmedia_vid_dev_stream *strm);
  726. /**
  727. * Destroy the stream.
  728. *
  729. * @param strm The video stream.
  730. *
  731. * @return PJ_SUCCESS on successful operation or the appropriate
  732. * error code.
  733. */
  734. PJ_DECL(pj_status_t) pjmedia_vid_dev_stream_destroy(
  735. pjmedia_vid_dev_stream *strm);
  736. /**
  737. * @}
  738. */
  739. PJ_END_DECL
  740. #endif /* __PJMEDIA_VIDEO_DEV_H__ */