summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfred <fred@home.lan>2011-04-09 23:01:17 (GMT)
committer fred <fred@home.lan>2011-04-09 23:01:17 (GMT)
commit0d51bed1c5c9fe0186fb48def11a5bc7b752f09a (patch)
tree112f6cb059670fcca73a6a82654fe833268a71f8
parent97640b1d450c99a5bd64a9252287d376ac4fb6e5 (diff)
In OggTheoraEncoder, test if shout_new succeeded.
- Also added possibility to see how long it takes between two thread_loops.
-rw-r--r--src/video_encoder.cpp36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/video_encoder.cpp b/src/video_encoder.cpp
index 45cfbd5..2cc2a1d 100644
--- a/src/video_encoder.cpp
+++ b/src/video_encoder.cpp
@@ -101,22 +101,27 @@ VideoEncoder::VideoEncoder()
ringbuffer = ringbuffer_create(1048*2096);
shout_init();
- ice = shout_new();
+ if ((ice = shout_new()) != NULL) {
- if( shout_set_protocol(ice,SHOUT_PROTOCOL_HTTP) )
- error("shout_set_protocol: %s", shout_get_error(ice));
+ if( shout_set_protocol(ice,SHOUT_PROTOCOL_HTTP) )
+ error("shout_set_protocol: %s", shout_get_error(ice));
- if( shout_set_format(ice,SHOUT_FORMAT_OGG) )
- error("shout_set_format: %s", shout_get_error(ice));
+ if( shout_set_format(ice,SHOUT_FORMAT_OGG) )
+ error("shout_set_format: %s", shout_get_error(ice));
- if( shout_set_agent(ice,"FreeJ - freej.dyne.org") )
- error("shout_set_agent: %s", shout_get_error(ice));
+ if( shout_set_agent(ice,"FreeJ - freej.dyne.org") )
+ error("shout_set_agent: %s", shout_get_error(ice));
- if( shout_set_public(ice,1) )
- error("shout_set_public: %s", shout_get_error(ice));
+ if( shout_set_public(ice,1) )
+ error("shout_set_public: %s", shout_get_error(ice));
+ }
func("init picture_yuv for colorspace conversion (avcodec)");
gettimeofday(&m_OldTime, NULL);
+
+ //uncomment this and beyond to see how long it takes between two frames
+/* m_OldTime.tv_sec = m_lastTime.tv_sec;
+ m_OldTime.tv_usec = m_lastTime.tv_usec;*/
}
VideoEncoder::~VideoEncoder() {
@@ -137,7 +142,7 @@ VideoEncoder::~VideoEncoder() {
nn = fwrite(encbuf, 1, encnum, filedump_fd);
}
- if(write_to_stream) {
+ if(write_to_stream && ice) {
shout_sync(ice);
shout_send(ice, (const unsigned char*)encbuf, encnum);
}
@@ -203,7 +208,14 @@ void VideoEncoder::thread_loop() {
}
fps->calc(); //without this the thread_loop is called nearly two times more and
fps->delay(); //stream speed is too slow
-
+ //uncomment this to see how long it takes between two frames in us.
+/* timeval start_t;
+ gettimeofday(&start_t,NULL);
+ timeval did;
+ timersub(&start_t, &m_lastTime, &did);
+ m_lastTime.tv_sec = start_t.tv_sec;
+ m_lastTime.tv_usec = start_t.tv_usec;
+ std::cerr << "diff time :" << did.tv_usec << std::endl;*/
screen->lock();
switch(screen->get_pixel_format()) {
@@ -256,7 +268,7 @@ void VideoEncoder::thread_loop() {
if(write_to_disk && filedump_fd)
fwrite(encbuf, 1, encnum, filedump_fd);
- if(write_to_stream) {
+ if(write_to_stream && ice) {
/* int wait_ms;
wait_ms = shout_delay(ice);
std::cerr << "---- shout delay :" << wait_ms << std::endl;*/