Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GStreamer_audioRecorder
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
m3
GStreamer_audioRecorder
Commits
820dc52c
Commit
820dc52c
authored
Aug 18, 2017
by
d.basulto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restart the connection and save partial buffer
parent
e0753bee
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
226 additions
and
213 deletions
+226
-213
StreamRecorder.cpp
StreamRecorder.cpp
+175
-169
StreamRecorder.h
StreamRecorder.h
+45
-39
StreamRecorder.o
StreamRecorder.o
+0
-0
main.cpp
main.cpp
+6
-5
main.o
main.o
+0
-0
No files found.
StreamRecorder.cpp
View file @
820dc52c
This diff is collapsed.
Click to expand it.
StreamRecorder.h
View file @
820dc52c
...
...
@@ -14,6 +14,7 @@
// your public header include
//------------------------------------------------------------------------------
#include <gst/gst.h>
#include <jmorecfg.h>
//------------------------------------------------------------------------------
#define STREAMRECORDER_SAMPLERATE 44100
#define READSIZE 1152 //For MPEG1, frame_size = 1152 samples/frame
...
...
@@ -22,46 +23,51 @@
//------------------------------------------------------------------------------
class
StreamRecorder
{
private
:
unsigned
int
nBytes
;
unsigned
int
bufferSize
;
unsigned
char
*
audioBuffer
;
unsigned
char
*
audioBufferPosition
;
int
recordTime
;
char
*
sourceName
;
GstElement
*
streamSrc
;
GstElement
*
audioConvert
;
GstElement
*
audioResample
;
GstElement
*
filterCaps
;
GstElement
*
queue0
;
GstElement
*
queue1
;
GstElement
*
filter
;
// GstElement* compressor;
// GstElement* queue2;
// GstElement* muxer;
// GstElement* fileSink;
GstElement
*
fakeSink
;
GstElement
*
audioSink
;
GstElement
*
mainPipeline
;
// GstElement* sinkPipeline;
private
:
GstElement
*
tempBin
;
int
createMainPipeline
();
// int createSinkPipeline();
int
connect
(
const
char
*
uri
);
int
disconnect
();
static
void
srcNewPad_callback
(
GstElement
*
element
,
GstPad
*
pad
,
void
*
data
);
static
int
bus_callback
(
GstBus
*
bus
,
GstMessage
*
message
,
void
*
data
);
// static void block_async_cb (GstPad * pad, gboolean blocked, gpointer user_data);
static
void
buffer_callback
(
GstElement
*
fakesink
,
GstBuffer
*
buffer
,
GstPad
*
pad
,
gpointer
user_data
);
static
int
filter_handoff_callback
(
GstElement
*
filter
,
GstBuffer
*
buffer
,
void
*
user_data
);
int
addToBuffer
(
unsigned
char
*
data
,
int
length
);
int
compressBuffer
();
int
saveWav
(
unsigned
char
*
data
,
int
size
)
const
;
void
printCaps
(
GstPad
*
pad
);
public
:
StreamRecorder
(
const
char
*
source
,
int
time
);
unsigned
int
nBytes
;
unsigned
int
bufferSize
;
unsigned
char
*
audioBuffer
;
unsigned
char
*
audioBufferPosition
;
int
recordTime
;
bool
isConnectionLost
;
char
*
pluginUri
;
//char* sourceName;
GstElement
*
streamSrc
;
GstElement
*
audioConvert
;
//GstElement* audioResample;
GstElement
*
filterCaps
;
GstElement
*
queue0
;
GstElement
*
queue1
;
GstElement
*
filter
;
GstElement
*
fakeSink
;
//GstElement* audioSink;
GstElement
*
mainPipeline
;
//GstElement* tempBin;
int
createMainPipeline
();
int
connect
(
const
char
*
uri
);
int
disconnect
();
// callbacks
static
void
srcNewPad_callback
(
GstElement
*
element
,
GstPad
*
pad
,
void
*
data
);
static
int
bus_callback
(
GstBus
*
bus
,
GstMessage
*
message
,
void
*
data
);
static
int
filter_handoff_callback
(
GstElement
*
filter
,
GstBuffer
*
buffer
,
void
*
user_data
);
// add data to buffer
int
addToBuffer
(
unsigned
char
*
data
,
int
length
);
int
compressBuffer
();
// Save information when connection fails
static
void
savePartialBuffer
(
void
*
user_data
);
// Restart the pipeline
static
gboolean
reconnectURIStream
(
void
*
data
);
public
:
StreamRecorder
(
const
char
*
source
,
int
time
);
};
//------------------------------------------------------------------------------
#endif
StreamRecorder.o
View file @
820dc52c
No preview for this file type
main.cpp
View file @
820dc52c
...
...
@@ -8,19 +8,20 @@
#include "StreamRecorder.h"
using
namespace
std
;
//------------------------------------------------------------------------------
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<
2
)
{
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<
3
)
{
cerr
<<
"too few arguments"
<<
endl
;
return
EXIT_FAILURE
;
}
gst_init
(
&
argc
,
&
argv
);
StreamRecorder
myRecorder
=
StreamRecorder
(
argv
[
1
],
atoi
(
argv
[
2
]));
GMainLoop
*
main_loop
=
NULL
;
main_loop
=
g_main_loop_new
(
NULL
,
FALSE
);
g_main_loop_run
(
main_loop
);
return
0
;
return
0
;
}
//------------------------------------------------------------------------------
main.o
View file @
820dc52c
No preview for this file type
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment