Skip to content

Commit 2cb5599

Browse files
author
Valentin Noel
committed
Add first version of StreamTranscoder class
1 parent c986108 commit 2cb5599

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
lines changed

src/AvTranscoder/StreamTranscoder.cpp

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
2+
#include "StreamTranscoder.hpp"
3+
4+
5+
/*
6+
InputFile : fichier
7+
8+
InputStream : déwrapper virtuel
9+
AvInputStream : déwrapper AV
10+
DummyInputStream : generate silence
11+
12+
InputStreamAudio : décoder audio
13+
InputStreamVideo : décoder video
14+
15+
OutputStreamAudio : encoder audio
16+
OutputStreamVideo : encoder video
17+
18+
OutputStream : encoder vide (futur: wrapper)
19+
OutputFile : fichier + wrapper virtuel
20+
21+
*/
22+
23+
namespace avtranscoder
24+
{
25+
26+
StreamTranscoder::StreamTranscoder( AvInputStream& stream, const bool isVideoStream )
27+
: _stream( &stream )
28+
, _inputStreamVideo( NULL )
29+
, _outputStreamVideo( NULL )
30+
, _inputStreamAudio( NULL )
31+
, _outputStreamAudio( NULL )
32+
, _isVideoStream( isVideoStream )
33+
, _transcodeStream( false )
34+
{
35+
// std::cout << "[StreamTranscoder::StreamTranscoder]" << std::endl;
36+
}
37+
38+
StreamTranscoder::~StreamTranscoder()
39+
{
40+
if( _inputStreamVideo )
41+
delete _inputStreamVideo;
42+
if( _outputStreamVideo )
43+
delete _outputStreamVideo;
44+
45+
if( _inputStreamAudio )
46+
delete _inputStreamAudio;
47+
if( _outputStreamAudio )
48+
delete _outputStreamAudio;
49+
}
50+
51+
void StreamTranscoder::init( const std::string& profile )
52+
{
53+
std::cout << "[StreamTranscoder::init] isVideoStream: " << _isVideoStream << std::endl;
54+
std::cout << "[StreamTranscoder::init] profile: " << profile << std::endl;
55+
56+
if( ! profile.empty() )
57+
{
58+
_transcodeStream = true;
59+
if( _isVideoStream )
60+
{
61+
std::cout << "[StreamTranscoder::init] video stream..." << std::endl;
62+
_inputStreamVideo = new InputStreamVideo( *_stream );
63+
_outputStreamVideo = new OutputStreamVideo();
64+
_outputStreamVideo->setProfile( profile );
65+
}
66+
else
67+
{
68+
std::cout << "[StreamTranscoder::init] audio stream..." << std::endl;
69+
_inputStreamAudio = new InputStreamAudio( *_stream );
70+
_outputStreamAudio = new OutputStreamAudio();
71+
_outputStreamAudio->setProfile( profile );
72+
}
73+
}
74+
}
75+
76+
bool StreamTranscoder::processFrame()
77+
{
78+
if( _transcodeStream )
79+
{
80+
// transcodes
81+
82+
}
83+
// wraps
84+
85+
return true;
86+
}
87+
88+
}

src/AvTranscoder/StreamTranscoder.hpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef _AV_TRANSCODER_STREAM_TRANSCODER_HPP_
2+
#define _AV_TRANSCODER_STREAM_TRANSCODER_HPP_
3+
4+
#include <AvTranscoder/AvInputStream.hpp>
5+
#include <AvTranscoder/InputStream.hpp>
6+
7+
#include <AvTranscoder/InputStreamVideo.hpp>
8+
#include <AvTranscoder/OutputStreamVideo.hpp>
9+
10+
#include <AvTranscoder/InputStreamAudio.hpp>
11+
#include <AvTranscoder/OutputStreamAudio.hpp>
12+
13+
namespace avtranscoder
14+
{
15+
16+
class StreamTranscoder
17+
{
18+
public:
19+
StreamTranscoder( AvInputStream& stream, const bool isVideoStream );
20+
~StreamTranscoder();
21+
22+
void init( const std::string& profile );
23+
24+
bool processFrame();
25+
26+
private:
27+
AvInputStream* _stream;
28+
29+
InputStreamVideo* _inputStreamVideo;
30+
OutputStreamVideo* _outputStreamVideo;
31+
32+
InputStreamAudio* _inputStreamAudio;
33+
OutputStreamAudio* _outputStreamAudio;
34+
35+
const bool _isVideoStream;
36+
37+
bool _transcodeStream;
38+
39+
};
40+
41+
}
42+
43+
#endif

0 commit comments

Comments
 (0)