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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
c6d3bd49
Commit
c6d3bd49
authored
13 years ago
by
Rafaël Carré
Browse files
Options
Downloads
Patches
Plain Diff
* #6345: Add a VideoPicture class and use it in video receiving
parent
77247c85
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_picture.h
+54
-0
54 additions, 0 deletions
sflphone-common/src/video/video_picture.h
sflphone-common/src/video/video_receive_thread.cpp
+12
-5
12 additions, 5 deletions
sflphone-common/src/video/video_receive_thread.cpp
with
66 additions
and
5 deletions
sflphone-common/src/video/video_picture.h
0 → 100644
+
54
−
0
View file @
c6d3bd49
/*
* Copyright (C) 2011 Savoir-Faire Linux Inc.
* Author: Rafaël Carré <rafael.carre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef __VIDEO_PICTURE_H__
#define __VIDEO_PICTURE_H__
namespace
sfl_video
{
class
VideoPicture
{
public:
VideoPicture
(
const
unsigned
bpp
,
const
unsigned
width
,
const
unsigned
height
,
const
uint64_t
pts
)
:
bpp
(
bpp
),
width
(
width
),
height
(
height
),
pts
(
pts
)
{
// FIXME : stride must be equal to width * bpp
data
=
malloc
(
Size
());
}
void
*
data
;
/** raw image data */
const
unsigned
bpp
;
/** bits per pixel */
const
unsigned
width
;
/** image width */
const
unsigned
height
;
/** image height */
const
uint64_t
pts
;
/** presentation timestamp */
size_t
Size
()
{
return
(
bpp
>>
3
)
*
width
*
height
;
}
};
}
#endif // __VIDEO_PICTURE_H__
This diff is collapsed.
Click to expand it.
sflphone-common/src/video/video_receive_thread.cpp
+
12
−
5
View file @
c6d3bd49
...
@@ -54,6 +54,7 @@ extern "C" {
...
@@ -54,6 +54,7 @@ extern "C" {
#include
<cstdlib>
#include
<cstdlib>
#include
"manager.h"
#include
"manager.h"
#include
"video_picture.h"
namespace
sfl_video
{
namespace
sfl_video
{
...
@@ -290,11 +291,6 @@ void VideoReceiveThread::setup()
...
@@ -290,11 +291,6 @@ void VideoReceiveThread::setup()
semSetID_
=
createSemSet
(
shmID_
,
shmKey_
,
&
semKey_
);
semSetID_
=
createSemSet
(
shmID_
,
shmKey_
,
&
semKey_
);
shmReady_
.
signal
();
shmReady_
.
signal
();
// assign appropriate parts of buffer to image planes in scaledPicture
avpicture_fill
(
reinterpret_cast
<
AVPicture
*>
(
scaledPicture_
),
reinterpret_cast
<
uint8_t
*>
(
shmBuffer_
),
(
enum
PixelFormat
)
format_
,
dstWidth_
,
dstHeight_
);
// allocate video frame
// allocate video frame
rawFrame_
=
avcodec_alloc_frame
();
rawFrame_
=
avcodec_alloc_frame
();
}
}
...
@@ -373,6 +369,8 @@ void VideoReceiveThread::run()
...
@@ -373,6 +369,8 @@ void VideoReceiveThread::run()
AVPacket
inpacket
;
AVPacket
inpacket
;
int
frameFinished
;
int
frameFinished
;
SwsContext
*
imgConvertCtx
=
createScalingContext
();
SwsContext
*
imgConvertCtx
=
createScalingContext
();
enum
PixelFormat
fmt
=
(
enum
PixelFormat
)
format_
;
int
bpp
=
(
av_get_bits_per_pixel
(
&
av_pix_fmt_descriptors
[
fmt
])
+
7
)
&
~
7
;
while
(
not
interrupted_
and
av_read_frame
(
inputCtx_
,
&
inpacket
)
>=
0
)
while
(
not
interrupted_
and
av_read_frame
(
inputCtx_
,
&
inpacket
)
>=
0
)
{
{
...
@@ -383,10 +381,19 @@ void VideoReceiveThread::run()
...
@@ -383,10 +381,19 @@ void VideoReceiveThread::run()
avcodec_decode_video2
(
decoderCtx_
,
rawFrame_
,
&
frameFinished
,
&
inpacket
);
avcodec_decode_video2
(
decoderCtx_
,
rawFrame_
,
&
frameFinished
,
&
inpacket
);
if
(
frameFinished
)
if
(
frameFinished
)
{
{
VideoPicture
*
pic
=
new
VideoPicture
(
bpp
,
dstWidth_
,
dstHeight_
,
rawFrame_
->
pts
);
// assign appropriate parts of buffer to image planes in scaledPicture
avpicture_fill
(
reinterpret_cast
<
AVPicture
*>
(
scaledPicture_
),
reinterpret_cast
<
uint8_t
*>
(
pic
->
data
),
fmt
,
dstWidth_
,
dstHeight_
);
sws_scale
(
imgConvertCtx
,
rawFrame_
->
data
,
rawFrame_
->
linesize
,
sws_scale
(
imgConvertCtx
,
rawFrame_
->
data
,
rawFrame_
->
linesize
,
0
,
decoderCtx_
->
height
,
scaledPicture_
->
data
,
0
,
decoderCtx_
->
height
,
scaledPicture_
->
data
,
scaledPicture_
->
linesize
);
scaledPicture_
->
linesize
);
// FIXME : put pictures in a pool and use the PTS to get them out and displayed from a separate thread
memcpy
(
shmBuffer_
,
pic
->
data
,
pic
->
Size
());
delete
pic
;
/* signal the semaphore that a new frame is ready */
/* signal the semaphore that a new frame is ready */
sem_signal
(
semSetID_
);
sem_signal
(
semSetID_
);
}
}
...
...
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