Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
f5a841d8
Commit
f5a841d8
authored
Nov 17, 2011
by
Tristan Matthews
Browse files
* #7845: fixed more Weffc++ warnings
parent
42ad4b61
Changes
16
Hide whitespace changes
Inline
Side-by-side
daemon/src/dbus/configurationmanager.cpp
View file @
f5a841d8
...
...
@@ -46,7 +46,7 @@ const char* ConfigurationManager::SERVER_PATH =
"/org/sflphone/SFLphone/ConfigurationManager"
;
ConfigurationManager
::
ConfigurationManager
(
DBus
::
Connection
&
connection
)
:
DBus
::
ObjectAdaptor
(
connection
,
SERVER_PATH
)
DBus
::
ObjectAdaptor
(
connection
,
SERVER_PATH
)
,
preview_
()
{}
std
::
map
<
std
::
string
,
std
::
string
>
ConfigurationManager
::
getIp2IpDetails
()
...
...
daemon/src/dbus/configurationmanager.h
View file @
f5a841d8
...
...
@@ -63,7 +63,6 @@ class ConfigurationManager
public
DBus
::
IntrospectableAdaptor
,
public
DBus
::
ObjectAdaptor
{
private:
std
::
vector
<
std
::
string
>
shortcutsKeys
;
// FIXME: this probably shouldn't live here
std
::
tr1
::
shared_ptr
<
sfl_video
::
VideoPreview
>
preview_
;
...
...
daemon/src/managerimpl.cpp
View file @
f5a841d8
...
...
@@ -71,7 +71,7 @@
ManagerImpl
::
ManagerImpl
()
:
preferences
(),
voipPreferences
(),
addressbookPreference
(),
hookPreference
(),
audioPreference
(),
shortcutPreferences
(),
hookPreference
(),
audioPreference
(),
videoPreference
(),
shortcutPreferences
(),
hasTriedToRegister_
(
false
),
audioCodecFactory
(),
dbus_
(),
config_
(),
currentCallId_
(),
currentCallMutex_
(),
audiodriver_
(
0
),
dtmfKey_
(
0
),
toneMutex_
(),
telephoneTone_
(
0
),
audiofile_
(
0
),
speakerVolume_
(
0
),
micVolume_
(
0
),
...
...
daemon/src/preferences.cpp
View file @
f5a841d8
...
...
@@ -409,9 +409,9 @@ void AudioPreference::unserialize(Conf::MappingNode *map)
}
VideoPreference
::
VideoPreference
()
:
device_
(),
channel_
(),
size_
(),
rate_
()
v4l2_list_
(
0
),
device_
(),
channel_
(),
size_
(),
rate_
()
{
v4l2_list_
=
new
VideoV4l2List
();
v4l2_list_
=
new
VideoV4l2List
Thread
();
v4l2_list_
->
start
();
}
...
...
daemon/src/preferences.h
View file @
f5a841d8
...
...
@@ -636,9 +636,10 @@ class VideoPreference : public Serializable
private:
NON_COPYABLE
(
VideoPreference
);
// V4L2 devices
sfl_video
::
VideoV4l2List
*
v4l2_list_
;
sfl_video
::
VideoV4l2List
Thread
*
v4l2_list_
;
std
::
string
device_
;
std
::
string
channel_
;
...
...
daemon/src/video/video_preview.cpp
View file @
f5a841d8
...
...
@@ -35,7 +35,9 @@
namespace
sfl_video
{
VideoPreview
::
VideoPreview
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
args
)
:
args_
(
args
)
{}
VideoPreview
::
VideoPreview
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
args
)
:
receiveThread_
(),
args_
(
args
),
shmKey_
(
0
),
semKey_
(
0
),
videoBufferSize_
(
0
)
{}
bool
VideoPreview
::
start
()
{
...
...
daemon/src/video/video_preview.h
View file @
f5a841d8
...
...
@@ -56,7 +56,6 @@ class VideoPreview {
int
semKey_
;
int
videoBufferSize_
;
};
}
#endif // __VIDEO_PREVIEW_H__
daemon/src/video/video_receive_thread.cpp
View file @
f5a841d8
...
...
@@ -379,11 +379,14 @@ void VideoReceiveThread::createScalingContext()
}
VideoReceiveThread
::
VideoReceiveThread
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
args
)
:
args_
(
args
),
test_source_
(
args_
[
"input"
]
==
"SFLTEST"
),
frameNumber_
(
0
),
shmBuffer_
(
0
),
shmID_
(
-
1
),
semSetID_
(
-
1
),
shmKey_
(
-
1
),
semKey_
(
-
1
),
videoBufferSize_
(
0
),
decoderCtx_
(
0
),
rawFrame_
(
0
),
scaledPicture_
(
0
),
...
...
@@ -391,9 +394,10 @@ VideoReceiveThread::VideoReceiveThread(const std::map<std::string, std::string>
inputCtx_
(
0
),
imgConvertCtx_
(
0
),
dstWidth_
(
-
1
),
dstHeight_
(
-
1
)
dstHeight_
(
-
1
),
shmReady_
(),
sdpFilename_
()
{
test_source_
=
(
args_
[
"input"
]
==
"SFLTEST"
);
setCancel
(
cancelDeferred
);
}
...
...
daemon/src/video/video_receive_thread.h
View file @
f5a841d8
...
...
@@ -34,7 +34,8 @@
#include
<cc++/thread.h>
#include
<map>
#include
<string>
#include
<limits.h>
#include
<climits>
#include
"noncopyable.h"
class
SwsContext
;
class
AVCodecContext
;
...
...
@@ -45,9 +46,10 @@ class AVFrame;
namespace
sfl_video
{
class
VideoReceiveThread
:
public
ost
::
Thread
{
private:
NON_COPYABLE
(
VideoReceiveThread
);
std
::
map
<
std
::
string
,
std
::
string
>
args_
;
bool
test_source_
;
unsigned
frameNumber_
;
std
::
map
<
std
::
string
,
std
::
string
>
args_
;
/*-------------------------------------------------------------*/
/* These variables should be used in thread (i.e. run()) only! */
...
...
@@ -84,9 +86,9 @@ class VideoReceiveThread : public ost::Thread {
virtual
void
run
();
void
waitForShm
();
int
getShmKey
()
{
return
shmKey_
;
}
int
getSemKey
()
{
return
semKey_
;
}
int
getVideoBufferSize
(
void
)
{
return
videoBufferSize_
;
}
int
getShmKey
()
const
{
return
shmKey_
;
}
int
getSemKey
()
const
{
return
semKey_
;
}
int
getVideoBufferSize
(
)
const
{
return
videoBufferSize_
;
}
};
}
...
...
daemon/src/video/video_rtp_session.cpp
View file @
f5a841d8
...
...
@@ -44,7 +44,8 @@
namespace
sfl_video
{
VideoRtpSession
::
VideoRtpSession
()
:
sending_
(
true
),
receiving_
(
true
)
VideoRtpSession
::
VideoRtpSession
()
:
sendThread_
(),
receiveThread_
(),
txArgs_
(),
rxArgs_
(),
sending_
(
true
),
receiving_
(
true
)
{
txArgs_
=
Manager
::
instance
().
videoPreference
.
getVideoSettings
();
txArgs_
[
"bitrate"
]
=
"500000"
;
...
...
@@ -52,7 +53,8 @@ VideoRtpSession::VideoRtpSession() : sending_(true), receiving_(true)
VideoRtpSession
::
VideoRtpSession
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
txArgs
,
const
std
::
map
<
std
::
string
,
std
::
string
>
&
rxArgs
)
:
txArgs_
(
txArgs
),
rxArgs_
(
rxArgs
),
sending_
(
true
),
receiving_
(
true
)
sendThread_
(),
receiveThread_
(),
txArgs_
(
txArgs
),
rxArgs_
(
rxArgs
),
sending_
(
true
),
receiving_
(
true
)
{}
void
VideoRtpSession
::
updateSDP
(
const
Sdp
&
sdp
)
...
...
daemon/src/video/video_send_thread.cpp
View file @
f5a841d8
...
...
@@ -303,6 +303,8 @@ void VideoSendThread::createScalingContext()
}
VideoSendThread
::
VideoSendThread
(
const
std
::
map
<
std
::
string
,
std
::
string
>
&
args
)
:
test_source_
(
false
),
sdpReady_
(),
args_
(
args
),
scaledPictureBuf_
(
0
),
outbuf_
(
0
),
...
...
@@ -316,7 +318,7 @@ VideoSendThread::VideoSendThread(const std::map<std::string, std::string> &args)
inputCtx_
(
0
),
outputCtx_
(
0
),
imgConvertCtx_
(
0
),
sdp_
(
""
)
sdp_
()
{
test_source_
=
(
args_
[
"input"
]
==
"SFLTEST"
);
setCancel
(
cancelDeferred
);
...
...
daemon/src/video/video_send_thread.h
View file @
f5a841d8
...
...
@@ -34,6 +34,7 @@
#include
<cc++/thread.h>
#include
<map>
#include
<string>
#include
"noncopyable.h"
class
SwsContext
;
class
AVCodecContext
;
...
...
@@ -46,12 +47,13 @@ namespace sfl_video {
class
VideoSendThread
:
public
ost
::
Thread
{
private:
bool
test_source_
;
NON_COPYABLE
(
VideoSendThread
)
;
void
forcePresetX264
();
void
print_and_save_sdp
();
void
setup
();
void
prepareEncoderContext
(
AVCodec
*
encoder
);
void
createScalingContext
();
bool
test_source_
;
ost
::
Event
sdpReady_
;
std
::
map
<
std
::
string
,
std
::
string
>
args_
;
...
...
daemon/src/video/video_v4l2.cpp
View file @
f5a841d8
...
...
@@ -125,18 +125,19 @@ static unsigned int pixelformat_score(unsigned pixelformat)
return
UINT_MAX
-
1
;
}
VideoV4l2Size
::
VideoV4l2Size
(
unsigned
height
,
unsigned
width
)
:
height
(
height
),
width
(
width
)
{}
VideoV4l2Size
::
VideoV4l2Size
(
unsigned
height
,
unsigned
width
)
:
height
(
height
),
width
(
width
),
rates_
()
{}
std
::
vector
<
std
::
string
>
VideoV4l2Size
::
getRateList
()
{
std
::
vector
<
std
::
string
>
v
;
std
::
stringstream
ss
;
size_t
n
=
rates
.
size
();
size_t
n
=
rates
_
.
size
();
unsigned
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
std
::
stringstream
ss
;
ss
<<
rates
[
i
];
ss
<<
rates
_
[
i
];
v
.
push_back
(
ss
.
str
());
}
...
...
@@ -144,10 +145,10 @@ std::vector<std::string> VideoV4l2Size::getRateList()
}
void
VideoV4l2Size
::
G
etFrameRates
(
int
fd
,
unsigned
int
pixel_format
)
void
VideoV4l2Size
::
g
etFrameRates
(
int
fd
,
unsigned
int
pixel_format
)
{
if
(
fd
==
-
1
)
{
// SFL_TEST
rates
.
push_back
(
30
);
rates
_
.
push_back
(
30
);
return
;
}
...
...
@@ -158,7 +159,7 @@ void VideoV4l2Size::GetFrameRates(int fd, unsigned int pixel_format)
frmival
.
height
=
height
;
if
(
ioctl
(
fd
,
VIDIOC_ENUM_FRAMEINTERVALS
,
&
frmival
))
{
rates
.
push_back
(
25
);
rates
_
.
push_back
(
25
);
ERROR
(
"could not query frame interval for size"
);
return
;
}
...
...
@@ -166,47 +167,47 @@ void VideoV4l2Size::GetFrameRates(int fd, unsigned int pixel_format)
switch
(
frmival
.
type
)
{
case
V4L2_FRMIVAL_TYPE_DISCRETE
:
do
{
rates
.
push_back
(
frmival
.
discrete
.
denominator
/
frmival
.
discrete
.
numerator
);
rates
_
.
push_back
(
frmival
.
discrete
.
denominator
/
frmival
.
discrete
.
numerator
);
frmival
.
index
++
;
}
while
(
!
ioctl
(
fd
,
VIDIOC_ENUM_FRAMEINTERVALS
,
&
frmival
));
break
;
case
V4L2_FRMIVAL_TYPE_CONTINUOUS
:
rates
.
push_back
(
25
);
rates
_
.
push_back
(
25
);
// TODO
ERROR
(
"Continuous Frame Intervals not supported"
);
break
;
case
V4L2_FRMIVAL_TYPE_STEPWISE
:
rates
.
push_back
(
25
);
rates
_
.
push_back
(
25
);
// TODO
ERROR
(
"Stepwise Frame Intervals not supported"
);
break
;
}
}
VideoV4l2Channel
::
VideoV4l2Channel
(
unsigned
idx
,
const
char
*
s
)
:
idx
(
idx
),
name
(
s
)
{
}
VideoV4l2Channel
::
VideoV4l2Channel
(
unsigned
idx
,
const
char
*
s
)
:
idx
(
idx
),
name
(
s
),
sizes_
()
{}
void
VideoV4l2Channel
::
S
etFourcc
(
unsigned
code
)
void
VideoV4l2Channel
::
s
etFourcc
(
unsigned
code
)
{
fourcc
[
0
]
=
code
;
fourcc
[
1
]
=
code
>>
8
;
fourcc
[
2
]
=
code
>>
16
;
fourcc
[
3
]
=
code
>>
24
;
fourcc
[
4
]
=
'\0'
;
fourcc
_
[
0
]
=
code
;
fourcc
_
[
1
]
=
code
>>
8
;
fourcc
_
[
2
]
=
code
>>
16
;
fourcc
_
[
3
]
=
code
>>
24
;
fourcc
_
[
4
]
=
'\0'
;
}
const
char
*
VideoV4l2Channel
::
G
etFourcc
()
const
char
*
VideoV4l2Channel
::
g
etFourcc
()
{
return
fourcc
;
return
fourcc
_
;
}
std
::
vector
<
std
::
string
>
VideoV4l2Channel
::
getSizeList
(
void
)
std
::
vector
<
std
::
string
>
VideoV4l2Channel
::
getSizeList
()
{
std
::
vector
<
std
::
string
>
v
;
size_t
n
=
sizes
.
size
();
unsigned
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
VideoV4l2Size
&
size
=
sizes
[
i
];
size_t
n
=
sizes_
.
size
();
for
(
size_t
i
=
0
;
i
<
n
;
++
i
)
{
VideoV4l2Size
&
size
=
sizes_
[
i
];
std
::
stringstream
ss
;
ss
<<
size
.
width
<<
"x"
<<
size
.
height
;
v
.
push_back
(
ss
.
str
());
...
...
@@ -217,12 +218,12 @@ std::vector<std::string> VideoV4l2Channel::getSizeList(void)
unsigned
int
VideoV4l2Channel
::
G
etSizes
(
int
fd
,
unsigned
int
pixelformat
)
unsigned
int
VideoV4l2Channel
::
g
etSizes
(
int
fd
,
unsigned
int
pixelformat
)
{
if
(
fd
==
-
1
)
{
//SFL_TEST
VideoV4l2Size
s
(
288
,
352
);
s
.
G
etFrameRates
(
-
1
,
0
);
sizes
.
push_back
(
s
);
s
.
g
etFrameRates
(
-
1
,
0
);
sizes
_
.
push_back
(
s
);
return
0
;
}
...
...
@@ -237,9 +238,9 @@ unsigned int VideoV4l2Channel::GetSizes(int fd, unsigned int pixelformat)
case
V4L2_FRMSIZE_TYPE_DISCRETE
:
do
{
VideoV4l2Size
size
(
frmsize
.
discrete
.
height
,
frmsize
.
discrete
.
width
);
size
.
G
etFrameRates
(
fd
,
frmsize
.
pixel_format
);
sizes
.
push_back
(
size
);
frmsize
.
index
++
;
size
.
g
etFrameRates
(
fd
,
frmsize
.
pixel_format
);
sizes
_
.
push_back
(
size
);
++
frmsize
.
index
;
}
while
(
!
ioctl
(
fd
,
VIDIOC_ENUM_FRAMESIZES
,
&
frmsize
));
return
pixelformat
;
...
...
@@ -263,13 +264,13 @@ fallback:
throw
std
::
runtime_error
(
"Couldnt get format"
);
VideoV4l2Size
size
(
fmt
.
fmt
.
pix
.
height
,
fmt
.
fmt
.
pix
.
width
);
size
.
G
etFrameRates
(
fd
,
fmt
.
fmt
.
pix
.
pixelformat
);
sizes
.
push_back
(
size
);
size
.
g
etFrameRates
(
fd
,
fmt
.
fmt
.
pix
.
pixelformat
);
sizes
_
.
push_back
(
size
);
return
fmt
.
fmt
.
pix
.
pixelformat
;
}
void
VideoV4l2Channel
::
G
etFormat
(
int
fd
)
void
VideoV4l2Channel
::
g
etFormat
(
int
fd
)
{
if
(
ioctl
(
fd
,
VIDIOC_S_INPUT
,
&
idx
))
throw
std
::
runtime_error
(
"VIDIOC_S_INPUT failed"
);
...
...
@@ -300,38 +301,34 @@ void VideoV4l2Channel::GetFormat(int fd)
throw
std
::
runtime_error
(
"Could not enumerate formats"
);
fmt
.
index
=
best_idx
;
pixelformat
=
G
etSizes
(
fd
,
pixelformat
);
pixelformat
=
g
etSizes
(
fd
,
pixelformat
);
S
etFourcc
(
pixelformat
);
s
etFourcc
(
pixelformat
);
}
VideoV4l2Size
VideoV4l2Channel
::
getSize
(
const
std
::
string
&
name
)
{
for
(
size_t
i
=
0
;
i
<
sizes
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
sizes
_
.
size
();
++
i
)
{
std
::
stringstream
ss
;
ss
<<
sizes
[
i
].
width
<<
"x"
<<
sizes
[
i
].
height
;
ss
<<
sizes
_
[
i
].
width
<<
"x"
<<
sizes
_
[
i
].
height
;
if
(
ss
.
str
()
==
name
)
return
sizes
[
i
];
return
sizes
_
[
i
];
}
return
sizes
.
back
();
return
sizes
_
.
back
();
}
VideoV4l2Device
::
VideoV4l2Device
(
int
fd
,
const
std
::
string
&
device
)
VideoV4l2Device
::
VideoV4l2Device
(
int
fd
,
const
std
::
string
&
device
)
:
device
(
device
),
name
(
"TEST"
),
channels
()
{
if
(
fd
==
-
1
)
{
VideoV4l2Channel
c
(
0
,
"#^&"
);
c
.
G
etSizes
(
-
1
,
0
);
c
.
g
etSizes
(
-
1
,
0
);
channels
.
push_back
(
c
);
name
=
"TEST"
;
this
->
device
=
device
;
return
;
}
unsigned
idx
;
v4l2_capability
cap
;
if
(
ioctl
(
fd
,
VIDIOC_QUERYCAP
,
&
cap
))
throw
std
::
runtime_error
(
"could not query capabilities"
);
...
...
@@ -343,6 +340,7 @@ VideoV4l2Device::VideoV4l2Device(int fd, const std::string &device)
v4l2_input
input
;
memset
(
&
input
,
0x0
,
sizeof
input
);
unsigned
idx
;
input
.
index
=
idx
=
0
;
while
(
!
ioctl
(
fd
,
VIDIOC_ENUMINPUT
,
&
input
))
{
if
(
idx
!=
input
.
index
)
...
...
@@ -350,23 +348,20 @@ VideoV4l2Device::VideoV4l2Device(int fd, const std::string &device)
if
(
input
.
type
&
V4L2_INPUT_TYPE_CAMERA
)
{
VideoV4l2Channel
channel
(
idx
,
(
const
char
*
)
input
.
name
);
channel
.
GetFormat
(
fd
);
channel
.
getFormat
(
fd
);
channels
.
push_back
(
channel
);
}
input
.
index
=
++
idx
;
}
this
->
device
=
device
;
}
std
::
vector
<
std
::
string
>
VideoV4l2Device
::
getChannelList
(
void
)
std
::
vector
<
std
::
string
>
VideoV4l2Device
::
getChannelList
(
)
const
{
std
::
vector
<
std
::
string
>
v
;
size_t
n
=
channels
.
size
();
unsigned
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
for
(
size_t
i
=
0
;
i
<
n
;
i
++
)
v
.
push_back
(
channels
[
i
].
name
);
return
v
;
...
...
daemon/src/video/video_v4l2.h
View file @
f5a841d8
...
...
@@ -52,14 +52,14 @@ class VideoV4l2Size {
/**
* @throw std::runtime_error
*/
void
G
etFrameRates
(
int
fd
,
unsigned
int
pixel_format
);
void
g
etFrameRates
(
int
fd
,
unsigned
int
pixel_format
);
std
::
vector
<
std
::
string
>
getRateList
();
unsigned
height
;
unsigned
width
;
private:
std
::
vector
<
float
>
rates
;
std
::
vector
<
float
>
rates
_
;
};
class
VideoV4l2Channel
{
...
...
@@ -69,24 +69,24 @@ class VideoV4l2Channel {
/**
* @throw std::runtime_error
*/
void
G
etFormat
(
int
fd
);
void
g
etFormat
(
int
fd
);
/**
* @throw std::runtime_error
*/
unsigned
int
G
etSizes
(
int
fd
,
unsigned
int
pixel_format
);
unsigned
int
g
etSizes
(
int
fd
,
unsigned
int
pixel_format
);
void
S
etFourcc
(
unsigned
code
);
const
char
*
G
etFourcc
();
void
s
etFourcc
(
unsigned
code
);
const
char
*
g
etFourcc
();
std
::
vector
<
std
::
string
>
getSizeList
(
void
);
std
::
vector
<
std
::
string
>
getSizeList
();
VideoV4l2Size
getSize
(
const
std
::
string
&
name
);
unsigned
idx
;
std
::
string
name
;
private:
std
::
vector
<
VideoV4l2Size
>
sizes
;
char
fourcc
[
5
];
std
::
vector
<
VideoV4l2Size
>
sizes
_
;
char
fourcc
_
[
5
];
};
class
VideoV4l2Device
{
...
...
@@ -99,7 +99,7 @@ class VideoV4l2Device {
std
::
string
device
;
std
::
string
name
;
std
::
vector
<
std
::
string
>
getChannelList
(
void
)
;
std
::
vector
<
std
::
string
>
getChannelList
(
)
const
;
VideoV4l2Channel
&
getChannel
(
const
std
::
string
&
name
);
...
...
daemon/src/video/video_v4l2_list.cpp
View file @
f5a841d8
...
...
@@ -62,53 +62,52 @@ namespace sfl_video {
static
int
is_v4l2
(
struct
udev_device
*
dev
)
{
const
char
*
version
;
version
=
udev_device_get_property_value
(
dev
,
"ID_V4L_VERSION"
);
const
char
*
version
=
udev_device_get_property_value
(
dev
,
"ID_V4L_VERSION"
);
/* we do not support video4linux 1 */
return
version
&&
strcmp
(
version
,
"1"
);
return
version
and
strcmp
(
version
,
"1"
);
}
VideoV4l2List
::
VideoV4l2List
()
:
_
udev_mon
(
NULL
)
VideoV4l2List
Thread
::
VideoV4l2List
Thread
()
:
devices_
(),
mutex_
(),
udev_
(
0
),
udev_mon
_
(
0
)
{
struct
udev_list_entry
*
devlist
;
struct
udev_enumerate
*
devenum
;
udev_list_entry
*
devlist
;
udev_enumerate
*
devenum
;
addDevice
(
"SFLTEST"
);
_
udev
=
udev_new
();
if
(
!
_
udev
)
udev
_
=
udev_new
();
if
(
!
udev
_
)
goto
udev_failed
;
_
udev_mon
=
udev_monitor_new_from_netlink
(
_
udev
,
"udev"
);
if
(
!
_
udev_mon
)
udev_mon
_
=
udev_monitor_new_from_netlink
(
udev
_
,
"udev"
);
if
(
!
udev_mon
_
)
goto
udev_failed
;
if
(
udev_monitor_filter_add_match_subsystem_devtype
(
_
udev_mon
,
"video4linux"
,
NULL
))
if
(
udev_monitor_filter_add_match_subsystem_devtype
(
udev_mon
_
,
"video4linux"
,
NULL
))
goto
udev_failed
;
/* Enumerate existing devices */
devenum
=
udev_enumerate_new
(
_
udev
);
devenum
=
udev_enumerate_new
(
udev
_
);
if
(
devenum
==
NULL
)
goto
udev_failed
;
if
(
udev_enumerate_add_match_subsystem
(
devenum
,
"video4linux"
))
if
(
udev_enumerate_add_match_subsystem
(
devenum
,
"video4linux"
))
{
udev_enumerate_unref
(
devenum
);
udev_enumerate_unref
(
devenum
);
goto
udev_failed
;
}
udev_monitor_enable_receiving
(
_
udev_mon
);
udev_monitor_enable_receiving
(
udev_mon
_
);
/* Note that we enumerate _after_ monitoring is enabled so that we do not
* loose device events occuring while we are enumerating. We could still
* loose events if the Netlink socket receive buffer overflows. */
udev_enumerate_scan_devices
(
devenum
);
devlist
=
udev_enumerate_get_list_entry
(
devenum
);
udev_enumerate_scan_devices
(
devenum
);
devlist
=
udev_enumerate_get_list_entry
(
devenum
);
struct
udev_list_entry
*
deventry
;
udev_list_entry_foreach
(
deventry
,
devlist
)
udev_list_entry_foreach
(
deventry
,
devlist
)
{
const
char
*
path
=
udev_list_entry_get_name
(
deventry
);
struct
udev_device
*
dev
=
udev_device_new_from_syspath
(
_
udev
,
path
);
const
char
*
path
=
udev_list_entry_get_name
(
deventry
);
struct
udev_device
*
dev
=
udev_device_new_from_syspath
(
udev
_
,
path
);
if
(
is_v4l2
(
dev
))
{
const
char
*
devpath
=
udev_device_get_devnode
(
dev
);
const
char
*
devpath
=
udev_device_get_devnode
(
dev
);
if
(
devpath
)
{
try
{
addDevice
(
devpath
);
...
...
@@ -117,9 +116,9 @@ VideoV4l2List::VideoV4l2List() : _udev_mon(NULL)
}
}
}
udev_device_unref
(
dev
);
udev_device_unref
(
dev
);
}
udev_enumerate_unref
(
devenum
);
udev_enumerate_unref
(
devenum
);
return
;
...
...
@@ -127,12 +126,12 @@ udev_failed:
ERROR
(
"udev enumeration failed"
);
if
(
_
udev_mon
)
udev_monitor_unref
(
_
udev_mon
);
if
(
_
udev
)
udev_unref
(
_
udev
);
_
udev_mon
=
NULL
;
_
udev
=
NULL
;
if
(
udev_mon
_
)
udev_monitor_unref
(
udev_mon
_
);
if
(
udev
_
)
udev_unref
(
udev
_
);
udev_mon
_
=
NULL
;
udev
_
=
NULL
;
/* fallback : go through /dev/video* */
int
idx
;
...
...
@@ -154,10 +153,9 @@ namespace {
int
GetNumber
(
const
std
::
string
&
name
,
size_t
*
sharp
)
{
size_t
len
=
name
.
length
();
if
(
len
<
3
)
{
// name is too short to be numbered
// name is too short to be numbered
if
(
len
<
3