1
/* $Id: errno.c 3715 2011-08-19 09:35:25Z nanang $ */
3
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#include <pjmedia-videodev/errno.h>
20
#include <pj/string.h>
21
#include <pj/unicode.h>
23
/* PJMEDIA-videodev's own error codes/messages
24
* MUST KEEP THIS ARRAY SORTED!!
25
* Message must be limited to 64 chars!
29
#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
32
#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
40
PJ_BUILD_ERR( PJMEDIA_EVID_ERR, "Unspecified video device error" ),
41
PJ_BUILD_ERR( PJMEDIA_EVID_SYSERR, "Unknown error from video driver" ),
42
PJ_BUILD_ERR( PJMEDIA_EVID_INIT, "video subsystem not initialized" ),
43
PJ_BUILD_ERR( PJMEDIA_EVID_INVDEV, "Invalid video device" ),
44
PJ_BUILD_ERR( PJMEDIA_EVID_NODEV, "Found no video devices" ),
45
PJ_BUILD_ERR( PJMEDIA_EVID_NODEFDEV, "Unable to find default video device" ),
46
PJ_BUILD_ERR( PJMEDIA_EVID_NOTREADY, "video device not ready" ),
47
PJ_BUILD_ERR( PJMEDIA_EVID_INVCAP, "Invalid or unsupported video capability" ),
48
PJ_BUILD_ERR( PJMEDIA_EVID_INVOP, "Invalid or unsupported video device operation" ),
49
PJ_BUILD_ERR( PJMEDIA_EVID_BADFORMAT, "Bad or invalid video device format" ),
50
PJ_BUILD_ERR( PJMEDIA_EVID_SAMPFORMAT, "Invalid video device sample format"),
51
PJ_BUILD_ERR( PJMEDIA_EVID_BADLATENCY, "Bad video latency setting")
55
#endif /* PJ_HAS_ERROR_STRING */
60
* pjmedia_videodev_strerror()
62
PJ_DEF(pj_str_t) pjmedia_videodev_strerror(pj_status_t statcode,
63
char *buf, pj_size_t bufsize )
67
#if defined(PJ_HAS_ERROR_STRING) && (PJ_HAS_ERROR_STRING != 0)
70
if (statcode >= PJMEDIA_VIDEODEV_ERRNO_START &&
71
statcode < PJMEDIA_VIDEODEV_ERRNO_END)
73
/* Find the error in the table.
77
int n = PJ_ARRAY_SIZE(err_str);
81
int mid = first + half;
83
if (err_str[mid].code < statcode) {
86
} else if (err_str[mid].code > statcode) {
95
if (PJ_ARRAY_SIZE(err_str) && err_str[first].code == statcode) {
98
msg.ptr = (char*)err_str[first].msg;
99
msg.slen = pj_ansi_strlen(err_str[first].msg);
102
pj_strncpy_with_null(&errstr, &msg, bufsize);
107
#endif /* PJ_HAS_ERROR_STRING */
109
/* Error not found. */
111
errstr.slen = pj_ansi_snprintf(buf, bufsize,
112
"Unknown pjmedia-videodev error %d",
119
#endif /* PJMEDIA_HAS_VIDEO */