Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
46dc2da7
Commit
46dc2da7
authored
14 years ago
by
Rafaël Carré
Browse files
Options
Downloads
Patches
Plain Diff
* #6179 : Move code from video_v4l2.h to video_v4l2.cpp
parent
ccdd3eba
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
sflphone-common/src/video/video_v4l2.cpp
+120
-0
120 additions, 0 deletions
sflphone-common/src/video/video_v4l2.cpp
sflphone-common/src/video/video_v4l2.h
+18
-92
18 additions, 92 deletions
sflphone-common/src/video/video_v4l2.h
with
138 additions
and
92 deletions
sflphone-common/src/video/video_v4l2.cpp
+
120
−
0
View file @
46dc2da7
...
@@ -124,6 +124,44 @@ static unsigned int pixelformat_score(unsigned pixelformat)
...
@@ -124,6 +124,44 @@ static unsigned int pixelformat_score(unsigned pixelformat)
return
UINT_MAX
-
1
;
return
UINT_MAX
-
1
;
}
}
VideoV4l2Size
::
VideoV4l2Size
(
unsigned
height
,
unsigned
width
)
:
height
(
height
),
width
(
width
),
_currentRate
(
0
)
{}
std
::
vector
<
std
::
string
>
VideoV4l2Size
::
getRateList
()
{
std
::
vector
<
std
::
string
>
v
;
std
::
stringstream
ss
;
size_t
n
=
rates
.
size
();
unsigned
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
VideoV4l2Rate
rate
=
rates
[
i
];
std
::
stringstream
ss
;
ss
<<
(
float
)
rate
.
den
/
rate
.
num
;
v
.
push_back
(
ss
.
str
());
}
return
v
;
}
void
VideoV4l2Size
::
setRate
(
unsigned
index
)
{
if
(
index
>=
rates
.
size
())
index
=
rates
.
size
()
-
1
;
_currentRate
=
index
;
}
unsigned
VideoV4l2Size
::
getRateIndex
()
{
return
_currentRate
;
}
VideoV4l2Rate
&
VideoV4l2Size
::
getRate
()
{
return
rates
[
_currentRate
];
}
void
VideoV4l2Size
::
GetFrameRates
(
int
fd
,
unsigned
int
pixel_format
)
void
VideoV4l2Size
::
GetFrameRates
(
int
fd
,
unsigned
int
pixel_format
)
{
{
struct
v4l2_frmivalenum
frmival
=
{
struct
v4l2_frmivalenum
frmival
=
{
...
@@ -162,6 +200,58 @@ void VideoV4l2Size::GetFrameRates(int fd, unsigned int pixel_format)
...
@@ -162,6 +200,58 @@ void VideoV4l2Size::GetFrameRates(int fd, unsigned int pixel_format)
}
}
}
}
VideoV4l2Channel
::
VideoV4l2Channel
(
unsigned
idx
,
const
char
*
s
)
:
idx
(
idx
),
name
(
s
),
_currentSize
(
0
)
{
}
void
VideoV4l2Channel
::
SetFourcc
(
unsigned
code
)
{
fourcc
[
0
]
=
code
;
fourcc
[
1
]
=
code
>>
8
;
fourcc
[
2
]
=
code
>>
16
;
fourcc
[
3
]
=
code
>>
24
;
fourcc
[
4
]
=
'\0'
;
}
const
char
*
VideoV4l2Channel
::
GetFourcc
()
{
return
fourcc
;
}
void
VideoV4l2Channel
::
setSize
(
unsigned
index
)
{
if
(
index
>=
sizes
.
size
())
index
=
sizes
.
size
()
-
1
;
_currentSize
=
index
;
}
std
::
vector
<
std
::
string
>
VideoV4l2Channel
::
getSizeList
(
void
)
{
std
::
vector
<
std
::
string
>
v
;
size_t
n
=
sizes
.
size
();
unsigned
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
VideoV4l2Size
&
size
=
sizes
[
i
];
std
::
stringstream
ss
;
ss
<<
size
.
width
<<
"x"
<<
size
.
height
;
v
.
push_back
(
ss
.
str
());
}
return
v
;
}
unsigned
VideoV4l2Channel
::
getSizeIndex
()
{
return
_currentSize
;
}
VideoV4l2Size
&
VideoV4l2Channel
::
getSize
()
{
return
sizes
[
_currentSize
];
}
unsigned
int
VideoV4l2Channel
::
GetSizes
(
int
fd
,
unsigned
int
pixelformat
)
unsigned
int
VideoV4l2Channel
::
GetSizes
(
int
fd
,
unsigned
int
pixelformat
)
{
{
struct
v4l2_frmsizeenum
frmsize
;
struct
v4l2_frmsizeenum
frmsize
;
...
@@ -271,4 +361,34 @@ VideoV4l2Device::VideoV4l2Device(int fd, const std::string &device) : _currentCh
...
@@ -271,4 +361,34 @@ VideoV4l2Device::VideoV4l2Device(int fd, const std::string &device) : _currentCh
this
->
device
=
device
;
this
->
device
=
device
;
}
}
std
::
vector
<
std
::
string
>
VideoV4l2Device
::
getChannelList
(
void
)
{
std
::
vector
<
std
::
string
>
v
;
size_t
n
=
channels
.
size
();
unsigned
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
v
.
push_back
(
channels
[
i
].
name
);
return
v
;
}
void
VideoV4l2Device
::
setChannel
(
unsigned
index
)
{
if
(
index
>=
channels
.
size
())
index
=
channels
.
size
()
-
1
;
_currentChannel
=
index
;
}
unsigned
VideoV4l2Device
::
getChannelIndex
()
{
return
_currentChannel
;
}
VideoV4l2Channel
&
VideoV4l2Device
::
getChannel
()
{
return
channels
[
_currentChannel
];
}
}
// end namespace sfl
}
// end namespace sfl
This diff is collapsed.
Click to expand it.
sflphone-common/src/video/video_v4l2.h
+
18
−
92
View file @
46dc2da7
...
@@ -55,47 +55,22 @@ class VideoV4l2Rate {
...
@@ -55,47 +55,22 @@ class VideoV4l2Rate {
class
VideoV4l2Size
{
class
VideoV4l2Size
{
public:
public:
VideoV4l2Size
(
unsigned
height
,
unsigned
width
)
:
height
(
height
),
width
(
width
),
_currentRate
(
0
)
{}
VideoV4l2Size
(
unsigned
height
,
unsigned
width
)
;
/**
/**
* @throw std::runtime_error
* @throw std::runtime_error
*/
*/
void
GetFrameRates
(
int
fd
,
unsigned
int
pixel_format
);
void
GetFrameRates
(
int
fd
,
unsigned
int
pixel_format
);
std
::
vector
<
std
::
string
>
getRateList
();
std
::
vector
<
std
::
string
>
getRateList
()
{
std
::
vector
<
std
::
string
>
v
;
std
::
stringstream
ss
;
size_t
n
=
rates
.
size
();
unsigned
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
VideoV4l2Rate
rate
=
rates
[
i
];
std
::
stringstream
ss
;
ss
<<
(
float
)
rate
.
den
/
rate
.
num
;
v
.
push_back
(
ss
.
str
());
}
return
v
;
}
void
setRate
(
unsigned
index
);
unsigned
getRateIndex
();
VideoV4l2Rate
&
getRate
();
unsigned
height
;
unsigned
height
;
unsigned
width
;
unsigned
width
;
void
setRate
(
unsigned
index
)
{
if
(
index
>=
rates
.
size
())
index
=
rates
.
size
()
-
1
;
_currentRate
=
index
;
}
unsigned
getRateIndex
()
{
return
_currentRate
;
}
VideoV4l2Rate
&
getRate
()
{
return
rates
[
_currentRate
];
}
private:
private:
std
::
vector
<
VideoV4l2Rate
>
rates
;
std
::
vector
<
VideoV4l2Rate
>
rates
;
unsigned
_currentRate
;
unsigned
_currentRate
;
...
@@ -103,7 +78,7 @@ class VideoV4l2Size {
...
@@ -103,7 +78,7 @@ class VideoV4l2Size {
class
VideoV4l2Channel
{
class
VideoV4l2Channel
{
public:
public:
VideoV4l2Channel
(
unsigned
idx
,
const
char
*
s
)
:
idx
(
idx
),
name
(
s
),
_currentSize
(
0
)
{
}
VideoV4l2Channel
(
unsigned
idx
,
const
char
*
s
)
;
/**
/**
* @throw std::runtime_error
* @throw std::runtime_error
...
@@ -114,47 +89,18 @@ class VideoV4l2Channel {
...
@@ -114,47 +89,18 @@ class VideoV4l2Channel {
*/
*/
unsigned
int
GetSizes
(
int
fd
,
unsigned
int
pixel_format
);
unsigned
int
GetSizes
(
int
fd
,
unsigned
int
pixel_format
);
void
SetFourcc
(
unsigned
code
)
{
void
SetFourcc
(
unsigned
code
);
fourcc
[
0
]
=
code
;
const
char
*
GetFourcc
();
fourcc
[
1
]
=
code
>>
8
;
fourcc
[
2
]
=
code
>>
16
;
fourcc
[
3
]
=
code
>>
24
;
fourcc
[
4
]
=
'\0'
;
}
const
char
*
GetFourcc
()
{
return
fourcc
;
}
unsigned
idx
;
std
::
string
name
;
void
setSize
(
unsigned
index
)
{
if
(
index
>=
sizes
.
size
())
index
=
sizes
.
size
()
-
1
;
_currentSize
=
index
;
}
std
::
vector
<
std
::
string
>
getSizeList
(
void
)
{
std
::
vector
<
std
::
string
>
v
;
size_t
n
=
sizes
.
size
();
void
setSize
(
unsigned
index
);
unsigned
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
VideoV4l2Size
&
size
=
sizes
[
i
];
std
::
stringstream
ss
;
ss
<<
size
.
width
<<
"x"
<<
size
.
height
;
v
.
push_back
(
ss
.
str
());
}
return
v
;
}
std
::
vector
<
std
::
string
>
getSizeList
(
void
);
unsigned
getSizeIndex
();
unsigned
getSizeIndex
()
{
VideoV4l2Size
&
getSize
();
return
_currentSize
;
}
VideoV4l2Size
&
getSize
()
{
unsigned
idx
;
return
sizes
[
_currentSize
];
std
::
string
name
;
}
private:
private:
std
::
vector
<
VideoV4l2Size
>
sizes
;
std
::
vector
<
VideoV4l2Size
>
sizes
;
...
@@ -172,30 +118,10 @@ class VideoV4l2Device {
...
@@ -172,30 +118,10 @@ class VideoV4l2Device {
std
::
string
device
;
std
::
string
device
;
std
::
string
name
;
std
::
string
name
;
std
::
vector
<
std
::
string
>
getChannelList
(
void
)
{
std
::
vector
<
std
::
string
>
getChannelList
(
void
);
std
::
vector
<
std
::
string
>
v
;
void
setChannel
(
unsigned
index
);
unsigned
getChannelIndex
();
size_t
n
=
channels
.
size
();
VideoV4l2Channel
&
getChannel
();
unsigned
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
v
.
push_back
(
channels
[
i
].
name
);
return
v
;
}
void
setChannel
(
unsigned
index
)
{
if
(
index
>=
channels
.
size
())
index
=
channels
.
size
()
-
1
;
_currentChannel
=
index
;
}
unsigned
getChannelIndex
()
{
return
_currentChannel
;
}
VideoV4l2Channel
&
getChannel
()
{
return
channels
[
_currentChannel
];
}
private:
private:
std
::
vector
<
VideoV4l2Channel
>
channels
;
std
::
vector
<
VideoV4l2Channel
>
channels
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment