[Sumover-dev] [svn commit] r4910 - in vic/branches/cc: . cc codec
net rtp tcl
sumover-dev at cs.ucl.ac.uk
sumover-dev at cs.ucl.ac.uk
Tue Oct 25 16:06:21 BST 2011
Author: piers
Date: Tue Oct 25 16:06:21 2011
New Revision: 4910
Added:
vic/branches/cc/video/grabber-file.cpp
- copied, changed from r4901, /vic/branches/cc/video/grabber-still.cpp
Removed:
vic/branches/cc/video/grabber-still.cpp
Modified:
vic/branches/cc/Makefile.in
vic/branches/cc/cc/tfrc_sndr.cpp
vic/branches/cc/cc/tfwc_sndr.cpp
vic/branches/cc/cc/tfwc_sndr.h
vic/branches/cc/codec/decoder.cpp
vic/branches/cc/codec/encoder-h261.cpp
vic/branches/cc/main.cpp
vic/branches/cc/module.cpp
vic/branches/cc/net/confbus.cpp
vic/branches/cc/net/mbus_handler.cpp
vic/branches/cc/rtp/session.cpp
vic/branches/cc/rtp/session.h
vic/branches/cc/rtp/source.h
vic/branches/cc/rtp/transmitter.cpp
vic/branches/cc/rtp/transmitter.h
vic/branches/cc/tcl/ui-ctrlmenu.tcl
vic/branches/cc/tcl/ui-grabber.tcl
vic/branches/cc/tcl/ui-main.tcl
vic/branches/cc/tcl/ui-resource.tcl
vic/branches/cc/video/grabber.cpp
vic/branches/cc/video/grabber.h
Log:
Updated VIC so that Soo-Hyun's TFRC support works with ECN. Fixes a number of bugs - new and old.
video/grabber.h
- Corrected description of frametime_ variable - as it is derived from fps_
video/grabber-still.cpp
- reverted to original jpeg still grabber
video/grabber-file.cpp
- Renamed from orig grabber-still and updated it
- Added correct return(TCL_OK) for file_load command
- Added #ifdef SUSPEND_GRAB around H261Encoder::suspend_grab() call
- Converted all fprintf(stderr...) to debug_msg(...)
video/grabber.cpp
- in tick(): renamed frametime to bpsframetime to better reflect its usage
tcl/ui-main.tcl
- Shrunk UI size by putting buttons below address in main GUI
- Added code to create filedev grabber obj early so decoder can be informed of it for PSNR calculation
tcl/ui-resource.tcl
- changed defaults for stillgrabber so it is enabled as default
- Created new stillFile resource to allow for setting of the filename
- Created new fileGrabberFile resource to allow for setting of the filename for fileGrabber
tcl/ui-ctrlmenu.tcl
- Added support setting StillGrabber filename from new stillGrabber resource
- Added support setting FileGrabber filename from new fileGrabberFile resource
- Removed still grabber disabling of controls
- Inform sessionmanager of grabber so it can control grabber bps
- Corrected bandwidth indicator units to be Kbps
tcl/ui-grabber.tcl
- Updated build.still with correct name and setting filename from resource
- Updated build.filegrab with correct name and setting filename from resource
- Both of the above use renamed proc set.file.frame to set the file name
cc/tfwc_sndr.h
- Added x_rate variable and xrate() return func - derived in the same way as TFRC - used for setting VIC send rate
- Converted all fprintf(stderr...) to debug_msg(...)
- Increased prev_history_[] size to HSZ+1 to match history[] size
cc/tfwc_sndr.cpp
- Added xrate calculation from TFRC sender code into window_in_packets()
- Corrected BUG in pseudo_history(): bzero history_ loop was exceeding array bounds by 1
- Corrected possible BUG: history revert was not copying entire array contents
cc/tfrc_sndr.cpp
- Corrected BUG in pseudo_history(): bzero history_ loop was exceeding array bounds by 1
codec/decoder.cpp
- Replace fprintf() with debug_msg()
codec/encoder-h261.cpp
- Added #ifdef ADJUST_QUANT around call to H261Encoder::adjust_quantizer() method in consume()
- Added bounds checking to adjust_quantizer()
- Corrected BUG in avg_packets_per_frame(): loop didn't cycle thru history values
- Converted all fprintf(stderr...) to debug_msg(...)
rtp/source.h
- Added associated access functions for ECN variables
rtp/transmitter.cpp
- Added associated code for setting Congestion Control (cc_type_) via command line
- txtime(): Commented out old tfrc block as VIC's own rate (kbps_) is used (which is now set to the CC algo's rate in SessionManager::parse_xr_records())
- tx_buf_size(): Fixed BUG in buffer traversal
- send(): commented out case RBCC as it doesn't appear to work. Instead TFRC mode just operates using VIC's normal rate control (which is controlled by TFRC algo's rate)
- send()/timeout(): Fixed OLD VIC BUG: 1e-3 used to convert secs to millisecs - should be 1e3 - meant that transmit scheduling was broken. Tho with TFRC there are few timeouts (but that probably depends on path characteristics).
- tfwc_output(_pb,ack_clock): corrected output so that packet buffer is emptied from the head of the list (as opposed to the tail - so only one packet was usually sent).
- tfwc_output(_pb,ack_clock): Moved b_magic() into while loop as it may change as loop progresses(?).
- tfrc_output() - Added comment saying that these routines are no longer used as the packet output in TFRC should be controlled via timers - in the normal vic output routines.
rtp/transmitter.h
- Added ECN defines
- Corrected bps() return value
rtp/session.cpp
- Added ecn-mode setting command
- Added grabber command for linking of grabber and session rate control
- Added control code for use of ecn-mode: Treat ECN as Loss(default) or Ignore
- parse_fb(): Added AVPF Feed Back(FB) packet parser for ECN for RTP support
- parse_xr_records(): Added sender rate control for grabber and session controller based on received Acks and TFRC algo.
- Removed some old cruft
rtp/session.h
- Added grabber connection member variable
- Added parse_fb() declaration
- Converted all fprintf(stderr...) to debug_msg(...)
module.cpp
- Added safety check when sending that tx_ object exists before attempting send
net/mbus_handler.cpp
- Added safety check when before scheduling heartbeat that mbusp_ object exists
net/confbus.cpp
- Added debug_msg() call.
Modified: vic/branches/cc/Makefile.in
==============================================================================
--- vic/branches/cc/Makefile.in (original)
+++ vic/branches/cc/Makefile.in Tue Oct 25 16:06:21 2011
@@ -134,7 +134,8 @@
net/net.o net/net-ip.o net/net-addr.o net/net-ipv6.o \
net/mbus_handler.o net/mbus_engine.o net/group-ipc.o net/confbus.o \
rtp/session.o rtp/source.o rtp/transmitter.o rtp/pktbuf-rtp.o \
- video/device.o video/grabber.o video/grabber-still.o \
+ video/device.o video/grabber.o \
+ video/grabber-still.o video/grabber-file.o \
codec/encoder-h261.o codec/encoder-jpeg.o codec/encoder-raw.o \
codec/encoder-h263.o codec/encoder-h263v2.o codec/encoder-nv.o \
codec/encoder-cellb.o codec/encoder-pvh.o codec/compositor.o \
Modified: vic/branches/cc/cc/tfrc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfrc_sndr.cpp (original)
+++ vic/branches/cc/cc/tfrc_sndr.cpp Tue Oct 25 16:06:21 2011
@@ -453,7 +453,7 @@
double pseudo_interval = 1.0 / p;
// bzero for all history information
- for (int i = 0; i <= HSZ+1; i++)
+ for (int i = 0; i <= HSZ; i++)
history_[i] = 0;
// let most recent history information be 0
history_[0] = 0;
Modified: vic/branches/cc/cc/tfwc_sndr.cpp
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.cpp (original)
+++ vic/branches/cc/cc/tfwc_sndr.cpp Tue Oct 25 16:06:21 2011
@@ -42,6 +42,7 @@
#include "module.h"
#include "transmitter.h"
#include "tfwc_sndr.h"
+#include "formula.h"
// TfwcSndr instance
TfwcSndr TfwcSndr::instance_;
@@ -188,11 +189,13 @@
// sequence number must be greater than zero
assert (seqno_ > 0);
+ if (seqno_ <= 0) debug_msg("WARNING: assert (seqno_(%d) > 0)",seqno_);
// number of total data packet sent
ndtp_++;
// set retransmission timer
set_rtx_timer();
+
}
/*
@@ -401,6 +404,11 @@
// finally, cwnd in bytes
window_in_bytes();
+
+ // calculate sending rate (bytes/sec) using same approach as TFRC - Piers
+ x_rate_ = p_to_b(p_, srtt_, t0_, psize_, 1);
+ debug_msg( "x_rate_ = %f (p_:%f srtt_:%f t0_:%f psize_:%d\n",
+ x_rate_ , p_, srtt_, t0_, psize_);
}
/*
@@ -488,11 +496,12 @@
num_refvec_ = end - begin + 1;
// generate refvec elements
- fprintf(stderr, "\tcomparing numbers: (");
+ //fprintf(stderr, "\tcomparing numbers: (");
for (int i = 0; i < num_refvec_; i++) {
refvec_[i] = begin + i;
- fprintf(stderr, " %d", refvec_[i]);
- } fprintf(stderr, " )\n");
+ //fprintf(stderr, " %d", refvec_[i]);
+ }
+ //fprintf(stderr, " )\n");
}
/*
@@ -622,6 +631,7 @@
// cwnd should always be greater than 1
if (cwnd_ < 1)
cwnd_ = 1;
+
}
/*
@@ -654,7 +664,7 @@
double pseudo = 1 / p;
/* bzero for all history information */
- for(int i = 0; i <= HSZ+1; i++)
+ for(int i = 0; i <= HSZ; i++)
history_[i] = 0;
/* (let) most recent history information be 0 */
@@ -793,17 +803,18 @@
int i = 0, j = 0;
// make a decision whether to include the most recent loss interval
- //fprintf(stderr, "\n\tHIST_0 [");
+ //fprintf(stderr, "\n\tHIST: hsz_ %d\n", hsz_);
+ //fprintf(stderr, "\tHIST_0 [");
for (i = 0; i < hsz_; i++) {
I_tot0_ += weight_[i] * history_[i];
tot_weight_ += weight_[i];
- // print_history_item(i);
+ print_history_item(i);
}
//fprintf(stderr, "]\n");
//fprintf(stderr, "\tHIST_1 [");
for (i = 1, j = 0; i < hsz_ + 1; i++, j++) {
I_tot1_ += weight_[i-1] * history_[i];
- // print_history_item(i, j);
+ print_history_item(i, j);
}
//fprintf(stderr, "]\n");
@@ -829,8 +840,8 @@
// store timestamp
prev_ts_ = ts;
// copy history
- for(int i = 0; i < hsz_; i++)
- prev_history_[i] = history_[i];
+ for(int i = 0; i <= hsz_; i++)
+ prev_history_[i] = history_[i];
}
/*
@@ -851,7 +862,7 @@
// reverting to the previous timestamp
ts_ = prev_ts_;
// reverting to the previous history
- for (int i = 0; i < hsz_; i++)
+ for (int i = 0; i <= hsz_; i++)
history_[i] = prev_history_[i];
print_ALI();
@@ -886,13 +897,13 @@
* print history item
*/
void TfwcSndr::print_history_item (int i) {
- fprintf(stderr, "%d", history_[i]);
- if (i < hsz_ - 1) fprintf(stderr, ", ");
+ //fprintf(stderr, "%d", history_[i]);
+ if (i < hsz_ - 1) ;//fprintf(stderr, ", ");
}
void TfwcSndr::print_history_item (int i, int j) {
- fprintf(stderr, "%d", history_[i]);
- if (j < hsz_ - 1) fprintf(stderr, ", ");
+ //fprintf(stderr, "%d", history_[i]);
+ if (j < hsz_ - 1) ;//fprintf(stderr, ", ");
}
/*
Modified: vic/branches/cc/cc/tfwc_sndr.h
==============================================================================
--- vic/branches/cc/cc/tfwc_sndr.h (original)
+++ vic/branches/cc/cc/tfwc_sndr.h Tue Oct 25 16:06:21 2011
@@ -77,9 +77,13 @@
// variables
u_int16_t seqno_; // packet sequence number
u_int32_t cwnd_; // congestion window
+ double x_rate_; // send rate (bytes/sec) - Piers
int bcwnd_; // congestion window in bytes
int bjacked_; // just ack'd in bytes
+ // return TFWC equivaent send rate - piers
+ inline double xrate() { return x_rate_; }
+
// Rtx timer
void expire(int option);
@@ -290,71 +294,71 @@
// print cwnd for debugging
inline void print_cwnd() {
- fprintf(stderr, "\tnow: %f\tcwnd: %d\n", so_recv_, cwnd_);
+ debug_msg( "\tnow: %f\tcwnd: %d\n", so_recv_, cwnd_);
}
// print bcwnd for debugging
inline void print_bcwnd (double now, int w) {
- fprintf(stderr, "\tnow: %f\tbcwnd: %d\n", now, w);
+ debug_msg( "\tnow: %f\tbcwnd: %d\n", now, w);
}
// print received XR chunk info
inline void print_xr_info(const char* str, const int i) {
- fprintf(stderr,
+ debug_msg(
" [%s +%d] begins: %d ends: %d jacked: %d\n",
str, i, begins_, ends_, jacked_);
}
// print RTT related info for debugging
inline void print_rtt_info() {
- fprintf(stderr,
+ debug_msg(
"\t>> now_: %f tsvec_[%d]: %f rtt: %f srtt: %f\n",
so_recv_, jacked_%TSZ, tsvec_[jacked_%TSZ], tao_, srtt_);
}
inline void print_rtt_info(const char* str) {
- fprintf(stderr,
+ debug_msg(
"\t%s now_: %f tsvec_[%d]: %f rtt: %f srtt: %f\n",
str, so_recv_, jacked_%TSZ, tsvec_[jacked_%TSZ], tao_, srtt_);
}
// print RTO info
inline void print_rto_info() {
- fprintf(stderr,
+ debug_msg(
"\t>> now_: %f rto: %f\n", now(), rto_);
}
// print ALI for debugging
inline void print_ALI() {
- fprintf(stderr, "\tnow: %f\tALI: %f\n\n", so_recv_, avg_interval_);
+ debug_msg( "\tnow: %f\tALI: %f\n\n", so_recv_, avg_interval_);
}
// print packet's timestamp record
inline void print_packet_tsvec() {
- fprintf(stderr, "\t>> now: %f tsvec_[%d]: %f\n",
+ debug_msg( "\t>> now: %f tsvec_[%d]: %f\n",
now_, seqno_%TSZ, tsvec_[seqno_%TSZ]);
}
// print mvec
inline void print_mvec() {
- fprintf(stderr, "\tmargin numbers: ( %d %d %d )\n",
+ debug_msg( "\tmargin numbers: ( %d %d %d )\n",
mvec_[0], mvec_[1], mvec_[2]);
}
// print vec
inline void print_vec(const char* str, u_int32_t *vec, int c) {
- fprintf(stderr, "\t%s: (", str);
+ debug_msg( "\t%s: (", str);
for (int i = 0; i < c; i++)
- fprintf(stderr, " %d", vec[i]);
- fprintf(stderr, " )\n");
+ debug_msg( " %d", vec[i]);
+ debug_msg( " )\n");
}
inline void print_vec(const char* str, u_int16_t *vec, int c) {
- fprintf(stderr, "\t%s: (", str);
+ debug_msg( "\t%s: (", str);
for (int i = 0; i < c; i++)
- fprintf(stderr, " %d", vec[i]);
- fprintf(stderr, " )\n");
+ debug_msg( " %d", vec[i]);
+ debug_msg( " )\n");
}
// print the actual packet size and EWMA estimated one
inline void print_psize(double now, int size, int len) {
- fprintf(stderr, "\tnow: %f psize: %d actual: %d\n", now, size, len);
+ debug_msg( "\tnow: %f psize: %d actual: %d\n", now, size, len);
}
int ndtp_; // number of data packet sent
@@ -378,7 +382,7 @@
double t_win_; // temporal cwin size to get p_ value
double avg_interval_; // average loss interval
int history_[HSZ+1]; // loss interval history
- int prev_history_[HSZ];// previous loss interval history
+ int prev_history_[HSZ+1];// previous loss interval history
double weight_[HSZ+1]; // weight for calculating avg loss interval
double I_tot_; // total sum
double I_tot0_; // from 0 to n-1
Modified: vic/branches/cc/codec/decoder.cpp
==============================================================================
--- vic/branches/cc/codec/decoder.cpp (original)
+++ vic/branches/cc/codec/decoder.cpp Tue Oct 25 16:06:21 2011
@@ -347,7 +347,7 @@
int framesize=inw_*inh_;
psnr = calc_psnr((u_int8_t*)frm, (u_int8_t*)grabber_->frame_+frame_no*(framesize+(framesize>>1)), inw_, inh_);
//psnr = calc_psnr((u_int8_t*)frm, (u_int8_t*)grabber_->frame_+frame_no*(grabber_->framesize_+(grabber_->framesize_>>1)), inw_, inh_);
- fprintf(stderr,"Frame (%dx%d;fsz:%d(%d),Grabber:%x): #%d, PSNR: %f\n",inw_,inh_,inw_*inh_, grabber_->framesize_,grabber_, frame_no, psnr);
+ debug_msg("Frame (%dx%d;fsz:%d(%d),Grabber:%x): #%d, PSNR: %f\n",inw_,inh_,inw_*inh_, grabber_->framesize_,grabber_, frame_no, psnr);
}
for (Renderer* p = engines_; p != 0; p = p->next_)
if ((p->ft() & FT_HW) == 0)
Modified: vic/branches/cc/codec/encoder-h261.cpp
==============================================================================
--- vic/branches/cc/codec/encoder-h261.cpp (original)
+++ vic/branches/cc/codec/encoder-h261.cpp Tue Oct 25 16:06:21 2011
@@ -201,39 +201,39 @@
int avg_packets_per_frame();
// print Tx queue info
- inline void print_txq_info() {
- fprintf(stderr, " now: %f\ttxq_now: %d\n",
- get_now(), tx_->tx_buf_size());
- }
- inline void print_txq_info(int len) {
- fprintf(stderr, " now: %f\ttxq_now: %d\n",
- get_now(), len);
- }
- inline void print_txq_info(int len, int dif) {
- fprintf(stderr, " now: %f\ttxq_now: %d\tdif: %d\n",
- get_now(), len, dif);
- }
- // print Tx queue sent more
- inline void print_sent_more() {
- fprintf(stderr, "\tnow: %f\tsent: %d more: %d vf[%d]: %d\n",
- get_now(), num_sent_, sent_more_,
- vfno_%FHSIZE, ppframe_[vfno_%FHSIZE]);
- }
- // print encoding time
- inline void print_enc_time() {
- fprintf(stderr, " now: %f\tenc_time: %f\n\n",
- get_now(), (enc_end_ - enc_start_));
- }
- // print packers per frame
- inline void print_ppframe() {
- fprintf(stderr, "\tnow: %f\tppframe[%d]: %d\n",
- get_now(), vfno_%FHSIZE, ppframe_[vfno_%FHSIZE]);
- }
- // print setq time
- inline void print_time_setq(int quant, double time) {
- fprintf(stderr, "now: %f duration: %f quant: %d\n",
- get_now(), get_now() - time, quant);
- }
+ inline void print_txq_info() {
+ debug_msg( " now: %f\ttxq_now: %d\n",
+ get_now(), tx_->tx_buf_size());
+ }
+ inline void print_txq_info(int len) {
+ debug_msg( " now: %f\ttxq_now: %d\n",
+ get_now(), len);
+ }
+ inline void print_txq_info(int len, int dif) {
+ debug_msg( " now: %f\ttxq_now: %d\tdif: %d\n",
+ get_now(), len, dif);
+ }
+ // print Tx queue sent more
+ inline void print_sent_more() {
+ debug_msg( "\tnow: %f\tsent: %d more: %d vf[%d]: %d\n",
+ get_now(), num_sent_, sent_more_,
+ vfno_%FHSIZE, ppframe_[vfno_%FHSIZE]);
+ }
+ // print encoding time
+ inline void print_enc_time() {
+ debug_msg( " now: %f\tenc_time: %f\n\n",
+ get_now(), (enc_end_ - enc_start_));
+ }
+ // print packers per frame
+ inline void print_ppframe() {
+ debug_msg( "\tnow: %f\tppframe[%d]: %d\n",
+ get_now(), vfno_%FHSIZE, ppframe_[vfno_%FHSIZE]);
+ }
+ // print setq time
+ inline void print_time_setq(int quant, double time) {
+ debug_msg( "now: %f duration: %f quant: %d\n",
+ get_now(), get_now() - time, quant);
+ }
private:
};
@@ -412,7 +412,7 @@
bloffsize_ = 1;
} else {
/*XXX*/
- fprintf(stderr, "H261PixelEncoder: H.261 bad geometry: %dx%d\n",
+ debug_msg( "H261PixelEncoder: H.261 bad geometry: %dx%d\n",
w, h);
exit(1);
}
@@ -462,7 +462,7 @@
bloffsize_ = 1;
} else {
/*XXX*/
- fprintf(stderr, "H261DCTEncoder: H.261 bad geometry: %dx%d\n",
+ debug_msg( "H261DCTEncoder: H.261 bad geometry: %dx%d\n",
w, h);
exit(1);
}
@@ -895,16 +895,16 @@
}
// ---------------------------------------------------------------*
- // adjust quantizer
+#ifdef ADJUST_QUANT
+ // adjust quantizer
adjust_quantizer(txq_beg_, avg_packets_per_frame());
+#endif
// increment frame number
- if (vfno_++%FHSIZE == 0)
- init_ppframe();
+ if (vfno_++%FHSIZE == 0) init_ppframe();
// check size
- if (!samesize(vf))
- size(vf->width_, vf->height_);
+ if (!samesize(vf)) size(vf->width_, vf->height_);
// main encoding loop
// (send packets while encoding)
@@ -918,6 +918,7 @@
// (these Tx'd packets may include the previous frame(s).)
num_sent_ = ppframe_[vfno_%FHSIZE] - txq_dif_;
+ debug_msg( " now: %f\t compressed frame size: %d\n", get_now(), cc);
print_txq_info(txq_end_, txq_dif_);
print_enc_time();
@@ -942,15 +943,16 @@
//print_time_setq(quantizer_, time);
}
else if (txq >= avg && txq < 3.5 * avg) {
- quantizer_++;
+ quantizer_ = (quantizer_ < 29) ? quantizer_ += 1 : quantizer_;
setq(quantizer_);
//print_time_setq(quantizer_, time);
}
else {
- quantizer_ += 2;
+ quantizer_ = (quantizer_ < 28) ? quantizer_ += 2 : quantizer_;
setq(quantizer_);
//print_time_setq(quantizer_, time);
}
+ print_time_setq(quantizer_, time);
}
int
@@ -958,7 +960,7 @@
{
// time measurement
enc_start_ = get_now();
- fprintf(stderr,">>>h261_encode_start\tnow: %f\n", enc_start_);
+ //fprintf(stderr,">>>h261_encode_start\tnow: %f\n", enc_start_);
tx_->flush();
@@ -1066,7 +1068,7 @@
// time measurement
enc_end_ = get_now();
- fprintf(stderr,"\n>>>h261_encode_end\tnow: %f\n", enc_end_);
+ //fprintf(stderr,"\n>>>h261_encode_end\tnow: %f\n", enc_end_);
return (cc);
}
@@ -1080,7 +1082,7 @@
if (k < 1) return 1;
for (int i = 0; i < k; i++)
- num += ppframe_[vfno_%FHSIZE];
+ num += ppframe_[(vfno_-i)%FHSIZE];
return (num /= k);
}
@@ -1095,15 +1097,14 @@
// highest watermark
int highmark = 0;
- if (vfno_ < FHSIZE)
- return false;
+ if (vfno_ < FHSIZE) return false;
// now, highmark is set to "m * (num packets per frame)",
// which roughly represents "m" frames.
highmark = m * avg_packets_per_frame();
+ debug_msg("TxQueue: %d, highmark: %d, vfno_: %d\n", txq, highmark, vfno_);
- if (txq > highmark)
- return true;
+ if (txq > highmark) return true;
return false;
}
Modified: vic/branches/cc/main.cpp
==============================================================================
--- vic/branches/cc/main.cpp (original)
+++ vic/branches/cc/main.cpp Tue Oct 25 16:06:21 2011
@@ -146,7 +146,7 @@
\t[-f bvc|cellb|h261|jpeg|nv|mpeg4|h264] [-F maxfps] [-i ifAddr ] [-I channel]\n\
\t[-K key ] [-L flowLabel (ip6 only)] [-l (creates log file)]\n\
\t[-M colormap] [-m mtu] [-N session] [-n atm|ip|ip6|rtip]\n\
- \t[-o clipfile] [-Q (queries and lists input devices)] [-t ttl]\n\
+ \t[-o clipfile] [-Q (queries and lists input devices)] [-t ttl]\n\
\t[-U interval] [-u script] [-v version] [-V visual]\n\
\t[-x ifIndex (ip6 only)] [-X resource=value] [-j numlayers] dest/port[/fmt/ttl]\n";
@@ -327,6 +327,9 @@
extern "C" int opterr;
#endif
+int cc_type__;
+int ecn_mode__;
+
const char*
parse_assignment(char* cp)
{
@@ -529,7 +532,7 @@
// Option list; If letter is followed by ':' then it takes an argument
const char* options =
- "A:B:C:c:D:d:f:F:HI:i:j:K:lL:M:m:N:n:o:Pq:QrsST:t:U:u:vV:w:x:X:y";
+ "A:B:C:c:D:d:e:E:f:F:HI:i:j:K:lL:M:m:N:n:o:Pq:QrsST:t:U:u:vV:w:x:X:y";
/* process display and window (-use) options before initialising tcl/tk */
char buf[256], tmp[256];
const char *display=0, *use=0;
@@ -647,6 +650,17 @@
case 'd':
break;
+ case 'e':
+ if (!strcasecmp(optarg,"RBCC")) cc_type__=RBCC;
+ else if (!strcasecmp(optarg,"WBCC")) cc_type__=WBCC;
+ else cc_type__=NOCC;
+ break;
+ case 'E':
+ if (!strcasecmp(optarg,"LOSS")) ecn_mode__=ECN_AS_LOSS;
+ else if (!strcmp(optarg,"ACT")) ecn_mode__=ECN_ACTION;
+ else ecn_mode__=ECN_AS_LOSS;
+ break;
+
case 'f':
tcl.add_option("defaultFormat", optarg);
break;
@@ -885,4 +899,3 @@
adios();
return (0);
}
-
Modified: vic/branches/cc/module.cpp
==============================================================================
--- vic/branches/cc/module.cpp (original)
+++ vic/branches/cc/module.cpp Tue Oct 25 16:06:21 2011
@@ -103,7 +103,7 @@
return (TclObject::command(argc, argv));
}
-TransmitterModule::TransmitterModule(int ft) : Module(ft)
+TransmitterModule::TransmitterModule(int ft) : Module(ft), tx_(0)
{
pool_ = new RTP_BufferPool;
}
@@ -122,8 +122,10 @@
return (TCL_OK);
}
if (strcmp(argv[1], "loop_layer") == 0) {
- tx_->loop_layer(atoi(argv[2]));
- return (TCL_OK);
+ if (tx_) {
+ tx_->loop_layer(atoi(argv[2]));
+ return (TCL_OK);
+ }
}
}
return (Module::command(argc, argv));
Modified: vic/branches/cc/net/confbus.cpp
==============================================================================
--- vic/branches/cc/net/confbus.cpp (original)
+++ vic/branches/cc/net/confbus.cpp Tue Oct 25 16:06:21 2011
@@ -121,6 +121,7 @@
if (!isascii(msg[i]) && !isprint(msg[i]))
return;
}
+ debug_msg("%s %s {%s}\n", callback_, name(), (char*)msg);
tcl.evalf("%s %s {%s}", callback_, name(), (char*)msg);
}
Modified: vic/branches/cc/net/mbus_handler.cpp
==============================================================================
--- vic/branches/cc/net/mbus_handler.cpp (original)
+++ vic/branches/cc/net/mbus_handler.cpp Tue Oct 25 16:06:21 2011
@@ -70,8 +70,12 @@
mbusp_ = mbus_init(cmd_handler, err_handler, mbus_vic_addr);
//unlink();
- // Schedule a heartbeat
- msched(50);
+ if (mbusp_) {
+ debug_msg("Mbus enabled\n");
+ // Schedule a heartbeat
+ msched(50);
+ } else
+ debug_msg("Mbus DISABLED - Probably due to multicast/Network problem\n");
}
void MBusHandler::listen_audio() {
Modified: vic/branches/cc/rtp/session.cpp
==============================================================================
--- vic/branches/cc/rtp/session.cpp (original)
+++ vic/branches/cc/rtp/session.cpp Tue Oct 25 16:06:21 2011
@@ -225,7 +225,8 @@
confid_(-1),
seqno_(0), // RTP data packet seqno (from RTP header)
lastseq_(0), // last received packet's seqno
-ackvec_(0) // bit vector (AckVec)
+ackvec_(0), // bit vector (AckVec)
+grabber_(0)
{
/*XXX For adios() to send bye*/
manager = this;
@@ -399,10 +400,19 @@
loopback_ = atoi(argv[2]);
return (TCL_OK);
}
+ if (strcmp(argv[1], "ecn-mode") == 0) {
+ ecn_mode_ = atoi(argv[2]);
+ return (TCL_OK);
+ }
if (strcmp(argv[1], "lip-sync") == 0) {
lipSyncEnabled_ = atoi(argv[2]);
return (TCL_OK);
}
+ if (strcmp(argv[1], "grabber") == 0) {
+ grabber_ = (Grabber*)TclObject::lookup(argv[2]);
+ fprintf(stderr,"Session:Setting this %d grabber_:%d\n", (int)this, (int)grabber_);
+ return (TCL_OK);
+ }
} else if (argc == 4) {
if (strcmp(argv[1], "data-net") == 0) {
@@ -451,6 +461,7 @@
return (TCL_ERROR);
}
+// Transmit RTP and DO send AoA
void SessionManager::transmit(pktbuf* pb, bool ack_clock)
{
// mh_.msg_iov = pb->iov;
@@ -490,6 +501,7 @@
}
}
+// Transmit RTP but DO NOT send AoA
void SessionManager::tx_data_only(pktbuf* pb, bool ack_clock)
{
// receive XR before sending
@@ -655,7 +667,7 @@
return (len);
}
-/*void SessionManager::send_ECN_FB(CtrlHandler* ch,
+/*void SessionManager::send_ECN_XR(CtrlHandler* ch,
u_int8_t tos, u_int16_t begin_seq)
{
u_int16_t chunk = (tos & 0x03) << 14;
@@ -890,7 +902,7 @@
fb_ecn->ect0 = htons(sl.ect0());
fb_ecn->ect1 = htons(sl.ect1());
- fprintf(stderr, "\t>> sending RTCP FB: seq_n_loss:%d(seq=%d), ecn_ecn:%d, not_ect:%d, ect0:%d, ect1:%d\n", ntohl(fb_ecn->seq_n_loss), seqno,ntohs(fb_ecn->ecn_ce), ntohs(fb_ecn->not_ect), ntohs(fb_ecn->ect0), ntohs(fb_ecn->ect1));
+ fprintf(stderr, "\t>> sending RTCP FB: seq_n_loss:%d(seq=%d), ecn_ecn:%d, not_ect:%d, ect0:%d,ect1:%d\n", ntohl(fb_ecn->seq_n_loss), seqno,ntohs(fb_ecn->ecn_ce), ntohs(fb_ecn->not_ect), ntohs(fb_ecn->ect0), ntohs(fb_ecn->ect1));
// FB packet length in bytes
int len = sizeof(rtcp_fb_ecn) + sizeof(rtcphdr);
@@ -1163,8 +1175,9 @@
Source::Layer& sl = s->layer(pb->layer);
timeval now = unixtime();
+ int ecn = dh_[0].net()->recvd_tos() & 0x03;
debug_msg("TOS byte:%d\n",dh_[0].net()->recvd_tos());
- switch (dh_[0].net()->recvd_tos() & 0x03) {
+ switch (ecn) {
case NOT_ECT:
sl.not_ect(1);
break;
@@ -1184,24 +1197,29 @@
// and send XR report back to the sender.
if (!am_i_sender()) {
// retrieve RTP seqno
+ extern int ecn_mode__;
seqno = ntohs(rh->rh_seqno);
- switch (cc_type_) {
- case WBCC:
- // pass seqno to tfwc receiver to build up AckVec
- fprintf(stderr, "\n\treceived seqno: %d\n\n", seqno);
- tfwc_rcvr_.recv_seqno(seqno);
- break;
- case RBCC:
- // pass seqno to tfrc receiver to build up AckVec
- fprintf(stderr, "\n\treceived seqno: %d\n\n", seqno);
- tfrc_rcvr_.recv_seqno(seqno);
- break;
- }
-
- // send receiver side XR report (AckVec)
- ch_->send_ackv();
- send_fb_ecn(ch_, sl, rh->rh_seqno, rh->rh_ssrc);
+ // if ECN_CE & ECN_AS_LOSS then act like packet is lost
+ if (!(ecn == ECN_CE && ecn_mode__ == ECN_AS_LOSS) ) {
+ switch (cc_type_) {
+ case WBCC:
+ // pass seqno to tfwc receiver to build up AckVec
+ fprintf(stderr, "\n\treceived seqno: %d", seqno);
+ tfwc_rcvr_.recv_seqno(seqno);
+ break;
+ case RBCC:
+ // pass seqno to tfrc receiver to build up AckVec
+ fprintf(stderr, "\n\treceived seqno: %d", seqno);
+ tfrc_rcvr_.recv_seqno(seqno);
+ break;
+ }
+ // Only send receiver side XR report (AckVec) when pkt not 'lost'
+ ch_->send_ackv();
+ debug_msg("NOT Treating ECN as LOSS (ecn:%d, mode:%d)\n",ecn,ecn_mode__);
+ } else
+ debug_msg("Treating ECN as LOSS (ecn:%d, mode:%d)\n",ecn,ecn_mode__);
+ send_fb_ecn(ch_, sl, seqno, ntohl(rh->rh_ssrc));
}
fprintf(stderr, "\n\treceived frame_no: %d\n\n", rh->frame_no);
@@ -1344,13 +1362,6 @@
sl.sts_ctrl(ntohl(sr->sr_ntp.upper) << 16 |
ntohl(sr->sr_ntp.lower) >> 16);
- //int cnt = flags >> 8 & 0x1f;
- //parse_rr_records(ssrc, (rtcp_rr*)(sr + 1), cnt, ep, addr);
-
- /*s->lts_ctrl(now);
- s->sts_ctrl(ntohl(sr->sr_ntp.upper) << 16 |
- ntohl(sr->sr_ntp.lower) >> 16);*/
-
s->rtp_ctrl(ntohl(sr->sr_ts));
u_int32_t t = ntptime(now);
s->map_ntp_time(t);
@@ -1376,6 +1387,37 @@
parse_rr_records(ssrc, (rtcp_rr*)(rh + 1), cnt, ep, addr);
}
+void SessionManager::parse_fb(rtcphdr* rh, int flags, u_char* ep,
+ Source* ps, Address & addr, int layer)
+{
+ Source* s;
+ u_int32_t ssrc = rh->rh_ssrc;
+ int fb_fmt = flags >>8 & 0x1f; // FB Format(FMT)
+
+ if (ps->srcid() != ssrc)
+ s = SourceManager::instance().lookup(ssrc, ssrc, addr);
+ else
+ s = ps;
+
+ Source::Layer& sl = s->layer(layer);
+
+ switch (fb_fmt) {
+ case RTPFB_FMT_ECN: {
+ struct rtcp_fb_ecn *fb_ecn = (rtcp_fb_ecn*)(rh + 1);
+ sl.lts_ctrl(unixtime());
+ sl.set_ecn_ce(ntohs(fb_ecn->ecn_ce));
+ sl.set_ect0(ntohs(fb_ecn->ect0));
+ sl.set_ect1(ntohs(fb_ecn->ect1));
+ sl.set_not_ect(ntohs(fb_ecn->not_ect));
+ debug_msg("Received RTCP ECN FB: seq_n_loss:%d, ecn_ecn:%d, not_ect:%d, ect0:%d, ect1:%d\n", ntohl(fb_ecn->seq_n_loss),ntohs(fb_ecn->ecn_ce), ntohs(fb_ecn->not_ect), ntohs(fb_ecn->ect0), ntohs(fb_ecn->ect1));
+ break;
+ }
+ default:
+ fprintf(stderr, "\t>> Received UNRECOGNISED RTCP FB packet FMT: %d\n", fb_fmt);
+ break;
+ }
+}
+
void SessionManager::parse_xr(rtcphdr* rh, int flags, u_char* ep,
Source* ps, Address & addr, int layer, bool ack_clock, pktbuf* pb)
{
@@ -1425,6 +1467,7 @@
// get SO_TIMESTAMP
so_rtime = ch_->net()->recvd_so_time() - tx_ts_offset();
//sender_xr_ts_info(so_rtime);
+ int xrate;
fprintf(stderr, ">>> parse_xr - i_am_sender\n");
fprintf(stderr, "\tincomingXR\tnow: %f\n", so_rtime);
@@ -1435,16 +1478,26 @@
// TFWC sender (getting AckVec)
tfwc_sndr_.recv(xr->BT,begin,end,chunk,so_rtime,ack_clock,pb);
// we need to call Transmitter::output(pb) to make Ack driven
+ xrate=(tfwc_sndr_.xrate()*8)/1000;
+ if (!xrate) xrate = 1;
+ bps(xrate);
+ if (grabber_) grabber_->bps(xrate);
+ debug_msg("now: %f Setting kbps: %d\n",so_rtime, kbps_);
if(ack_clock)
- tfwc_output(ack_clock);
+ tfwc_output(ack_clock);
break;
case RBCC:
// TFRC sender (getting AckVec)
tfrc_sndr_.recv(xr->BT,begin,end,chunk,so_rtime,ack_clock,pb);
+ xrate=(tfrc_sndr_.xrate()*8)/1000;
+ if (!xrate) xrate = 1;
+ bps(xrate);
+ if (grabber_) grabber_->bps(xrate);
+ debug_msg("now: %f Setting kbps: %d\n",so_rtime, kbps_);
// XXX
if(ack_clock)
- tfrc_output(ack_clock);
+ tfrc_output(ack_clock);
break;
} // switch (cc_type_)
}
@@ -1519,6 +1572,7 @@
// here, we expect it to be XR only.
switch(ntohs(rh->rh_flags) & 0xc0ff) {
case RTP_VERSION << 14 | RTCP_PT_XR:
+ case RTP_VERSION << 14 | RTCP_PT_RTPFB:
break;
case RTP_VERSION << 14 | RTCP_PT_SR:
case RTP_VERSION << 14 | RTCP_PT_RR:
@@ -1568,6 +1622,7 @@
case RTCP_PT_XR:
rtcp_pkt_id = RTCP_PT_XR;
parse_xr(rh, flags, ep, ps, addr, layer, !(ack_clock), pb);
+ debug_msg("SessionManager::recv_xreport: parsed RTCP XR packet %d\n", rtcp_pkt_id);
break;
case RTCP_PT_SR:
rtcp_pkt_id = RTCP_PT_SR;
@@ -1579,7 +1634,13 @@
rtcp_pkt_id = RTCP_PT_SDES;
debug_msg("warning: wrong RTCP packet type! %d\n", rtcp_pkt_id);
return 0;
+ case RTCP_PT_RTPFB:
+ debug_msg("Received: RTCP FB packet type %d\n", flags & 0xff);
+ parse_fb(rh, flags, ep, ps, addr, layer);
+ break;
+
default:
+ debug_msg("warning: Unrecognised RTCP packet type! %d\n", flags & 0xff);
ps->badsessopt(1);
break;
}
@@ -1749,6 +1810,7 @@
case RTP_VERSION << 14 | RTCP_PT_SR:
case RTP_VERSION << 14 | RTCP_PT_RR:
case RTP_VERSION << 14 | RTCP_PT_XR:
+ case RTP_VERSION << 14 | RTCP_PT_RTPFB:
case RTP_VERSION << 14 | RTCP_PT_BYE:
break;
default:
@@ -1768,7 +1830,7 @@
Address & addr = *srcp;
/*
- * First record in compount packet must be the ssrc of the
+ * First record in compound packet must be the ssrc of the
* sender of the packet. Pull it out here so we can use
* it in the sdes parsing, since the sdes record doesn't
* contain the ssrc of the sender (in the case of mixers).
@@ -1800,17 +1862,25 @@
switch (flags & 0xff) {
case RTCP_PT_SR:
+ debug_msg("Received: RTCP SR packet type %d\n", flags & 0xff);
parse_sr(rh, flags, ep, ps, addr, layer);
break;
case RTCP_PT_RR:
+ debug_msg("Received: RTCP RR packet type %d\n", flags & 0xff);
parse_rr(rh, flags, ep, ps, addr, layer);
break;
case RTCP_PT_XR:
+ debug_msg("Received: RTCP XR packet type %d\n", flags & 0xff);
parse_xr(rh, flags, ep, ps, addr, layer, 1);
break;
+ case RTCP_PT_RTPFB:
+ debug_msg("Received: RTCP FB packet type %d\n", flags & 0xff);
+ parse_fb(rh, flags, ep, ps, addr, layer);
+ break;
+
case RTCP_PT_SDES:
parse_sdes(rh, flags, ep, ps, addr, ssrc, layer);
break;
Modified: vic/branches/cc/rtp/session.h
==============================================================================
--- vic/branches/cc/rtp/session.h (original)
+++ vic/branches/cc/rtp/session.h Tue Oct 25 16:06:21 2011
@@ -43,6 +43,7 @@
#include "iohandler.h"
#include "source.h"
#include "mbus_handler.h"
+#include "grabber.h"
class Source;
class SessionManager;
@@ -123,7 +124,7 @@
// control channel dispatch debug info
inline void dispatch_info(double now, int nbytes, int i) {
- fprintf(stderr, " \tnow: %f\tdispatched[%d]: %d\n",now,i,nbytes);
+ debug_msg( " \tnow: %f\tdispatched[%d]: %d\n",now,i,nbytes);
}
};
@@ -186,6 +187,8 @@
Source* ps, Address & addr, int layer);
void parse_rr(rtcphdr* rh, int flags, u_char* ep,
Source* ps, Address & addr, int layer);
+ void parse_fb(rtcphdr* rh, int flags, u_char* ep,
+ Source* ps, Address & addr, int layer);
void parse_xr(rtcphdr* rh, int flags, u_char* ep,
Source* ps, Address & addr, int layer, bool ack_clock, pktbuf* pb=0);
void parse_rr_records(u_int32_t ssrc, rtcp_rr* r, int cnt,
@@ -246,46 +249,47 @@
u_int16_t ackvec_; // this is a bit vector
// timestamp
double recv_ts_; // receive timestamp
+ Grabber *grabber_; // grabber pointer - set by a tcl command piers
private:
// print RTP data packet's seqno
inline void print_rtp_seqno(u_int16_t seqno) {
- fprintf(stderr, "\n\tnow: %f\tseqno: %d\n\n",tx_get_now(),seqno);
+ debug_msg( "\n\tnow: %f\tseqno: %d\n\n",tx_get_now(),seqno);
}
inline void print_rtp_seqno(pktbuf* pb) {
rtphdr* rh = (rtphdr *) pb->data;
- fprintf(stderr, "\n\tnow: %f\tseqno: %d\n\n",
+ debug_msg( "\n\tnow: %f\tseqno: %d\n\n",
tx_get_now(),ntohs(rh->rh_seqno));
}
// print sender's XR info
inline void sender_xr_info(const char* str, const int i,
u_int16_t b, u_int16_t e, rtcp_xr_BT_1_hdr* xrh, u_int16_t l) {
- fprintf(stderr, " [%s +%d] beg:%d, end:%d, xr1len:%d (xrlen:%d)\n",
+ debug_msg( " [%s +%d] beg:%d, end:%d, xr1len:%d (xrlen:%d)\n",
str, i, b, e, ntohs(xrh->xr_len),l);
}
// print sender's XR info
inline void sender_xr_ts_info(double ts) {
- fprintf(stderr, "*** recv_ts: %f so_rtime: %f diff: %f\n",
+ debug_msg( "*** recv_ts: %f so_rtime: %f diff: %f\n",
recv_ts_, ts, recv_ts_-ts);
}
// print receiver's XR info
inline void receiver_xr_info(const char* str, const int i, u_int16_t *c) {
- fprintf(stderr, " [%s +%d] chunk[0]:%d\n",str, i, ntohs(c[0]));
+ debug_msg( " [%s +%d] chunk[0]:%d\n",str, i, ntohs(c[0]));
}
// print parse XR banner
inline void parse_xr_banner_top() {
- fprintf(stderr,
+ debug_msg(
"~~~~~~~~~~~~~~~~~~entering parse_xr_records()~~~~~~~~~~~~~~~~~~\n");
}
inline void parse_xr_banner_bottom() {
- fprintf(stderr,
+ debug_msg(
"-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-\n");
}
inline void xr_arrival_info(int nbytes, int i) {
- fprintf(stderr, " \tnow: %f\tnbytes[%d]: %d\n",tx_get_now(),i,nbytes);
+ debug_msg( " \tnow: %f\tnbytes[%d]: %d\n",tx_get_now(),i,nbytes);
}
inline void send_xr_info(int bt, u_int16_t b, u_int16_t e){
- fprintf(stderr, "\tBT: %d\tnow: %f begin: %d end: %d\n",
+ debug_msg( "\tBT: %d\tnow: %f begin: %d end: %d\n",
bt, tx_get_now(), b, e);
}
};
Modified: vic/branches/cc/rtp/source.h
==============================================================================
--- vic/branches/cc/rtp/source.h (original)
+++ vic/branches/cc/rtp/source.h Tue Oct 25 16:06:21 2011
@@ -240,6 +240,10 @@
inline void not_ect(int v) { not_ect_ += v; }
inline void ect0(int v) { ect0_ += v; }
inline void ect1(int v) { ect1_ += v; }
+ inline void set_ecn_ce(int v) { ecn_ce_ = v; }
+ inline void set_not_ect(int v) { not_ect_ = v; }
+ inline void set_ect0(int v) { ect0_ = v; }
+ inline void set_ect1(int v) { ect1_ = v; }
inline const timeval& lts_ctrl() const { return (lts_ctrl_); }
inline const timeval& lts_data() const { return (lts_data_); }
Modified: vic/branches/cc/rtp/transmitter.cpp
==============================================================================
--- vic/branches/cc/rtp/transmitter.cpp (original)
+++ vic/branches/cc/rtp/transmitter.cpp Tue Oct 25 16:06:21 2011
@@ -82,6 +82,8 @@
*/
u_int16_t Transmitter::seqno_ = 1;
+extern int cc_type__;
+
Transmitter::Transmitter() :
mtu_(1024),
nf_(0),
@@ -96,8 +98,8 @@
loopback_(0),
is_cc_active_(1),
is_buf_empty_(1),
- cc_type_(NOCC),
- cwnd_mode_(BYM)
+ cc_type_(cc_type__),
+ cwnd_mode_(PKM)
{
memset((char*)&mh_, 0, sizeof(mh_));
mh_.msg_iovlen = 2;
@@ -110,6 +112,7 @@
tfwc_sndr_.manager(this);
tfwc_rcvr_.manager(this);
+ debug_msg("CC type: WBCC\n");
break;
case RBCC:
@@ -118,15 +121,18 @@
tfrc_sndr_.manager(this);
tfrc_rcvr_.manager(this);
+ debug_msg("CC type: RBCC\n");
break;
+ default:
+ debug_msg("CC type: NOCC\n");
}
epc_ = 0; // experimental packet counter
}
/* Return time of day in seconds */
-inline double Transmitter::gettimeofday_secs() const
+double Transmitter::gettimeofday_secs() const
{
timeval tv;
::gettimeofday(&tv, 0);
@@ -137,7 +143,7 @@
{
int layer = pb->layer;
rtphdr* rh = (rtphdr*)pb->data;
- fprintf(stderr, "loopback received frame_no: %d\n", rh->frame_no);
+ debug_msg( "loopback received frame_no: %d\n", rh->frame_no);
int cc = pb->len;
/*
* Update statistics.
@@ -166,6 +172,7 @@
if (flags & RTP_M) {
++nf_;
sl.nf(1);
+ debug_msg("now: %f loopback received last packet of frame_no: %d ",tx_get_now(), rh->frame_no);
}
int fmt = flags & 0x7f;
/*
@@ -234,12 +241,17 @@
*/
double Transmitter::txtime(pktbuf* pb)
{
-// int cc = pb->iov[0].iov_len + pb->iov[1].iov_len;
int cc = pb->len;
- if (is_tfrc())
+ /* Commented out this with change setting bps(xrate)
+ fprintf(stderr,"TFRC txtime: %f, (cc: %d / xrate: %f) \n", cc/tfrc_sndr_.xrate(),
+ cc,tfrc_sndr_.xrate());
+ if (is_tfrc()){
+ fprintf(stderr,"txtime: %f, (cc: %d / xrate: %f) \n", cc/tfrc_sndr_.xrate(),
+ cc,tfrc_sndr_.xrate());
return ( cc/tfrc_sndr_.xrate() );
- else
+ }else */
+ debug_msg("txtime: psize: %d, kbps_: %d\n", cc ,kbps_);
return (8 * cc / (1000. * kbps_));
}
@@ -248,14 +260,16 @@
*/
int Transmitter::tx_buf_size() {
int size = 0;
- pktbuf* pb = head_;
+ pktbuf *pb = head_, *pbnext;
while (pb) {
+ pbnext = pb->next;
+ pb = pbnext;
size++;
- pb = pb->next;
- }
+ }
return size;
}
+// Entry point from codec
void Transmitter::send(pktbuf* pb)
{
switch (cc_type_) {
@@ -289,7 +303,8 @@
//
// rate-based congestion control (TFRC)
//
- case RBCC:
+ // Disable this version as I don't think it works - Piers
+ /*case RBCC:
// pb is empty
if(is_buf_empty_) {
if (head_ != 0) {
@@ -311,24 +326,31 @@
pb->next = 0;
tfrc_output(pb);
}
- break;
+ break;*/
//
// without congestion control
//
+ case RBCC:
case NOCC:
default:
// CC is not active, so just go for the normal operation
if (!busy_) {
double delay = txtime(pb);
nextpkttime_ = gettimeofday_secs() + delay;
+ int intdelay = int(delay * 1e3);
output(pb);
/*
* emulate a transmit interrupt --
* assume we will have more to send.
*/
- msched(int(delay * 1e-3));
- busy_ = 1;
+ debug_msg("Send:ing packet, delay till next send: %f(%d)\n",delay,intdelay);
+
+ if (intdelay) {
+ msched(intdelay);
+ busy_ = 1;
+ }
} else {
+ debug_msg("Send: Adding packet to txq (time: %f)\n", gettimeofday_secs());
if (head_ != 0) {
tail_->next = pb;
tail_ = pb;
@@ -338,9 +360,13 @@
}
} // switch (cc_type)
}
+
+// main TFWC CC output routines (called when NOT buff_is_empty)
-void Transmitter::tfwc_output(pktbuf* pb, bool ack_clock)
+void Transmitter::tfwc_output(pktbuf* _pb, bool ack_clock)
{
+ // Set pb to head_ of list (the arg pb is at the tail - Piers)
+ pktbuf *pb = head_;
//cc_output_banner_top("tfwc");
// byte mode? or packet mode?
switch (cwnd_mode_) {
@@ -348,18 +374,23 @@
{
// see if any XR has arrived to pick up
int cc = check_xr_arrival(pb, 1);
+ int i=0;
+ debug_msg("B4 tfwc_output: %d cc:%d, pblen: %d\n", tfwc_sndr_.b_magic(), cc, pb->len);
while(pb->len <= tfwc_sndr_.b_magic() + cc) {
// move head pointer
head_ = pb->next;
// call Transmitter::output_data_only w/ XR reception
+ debug_msg("tfwc_output: %d cc:%d, pblen: %d\n", tfwc_sndr_.b_magic(), cc, pb->len);
output_data_only(pb, ack_clock);
+ i++;
if (head_ != 0)
pb = head_;
else
break;
}
+ debug_msg("tfwc_outputed: %d (txq: %d)\n", i, tx_buf_size());
}
break;
case PKM:
@@ -370,17 +401,18 @@
check_xr_arrival(pb, 1);
while (ntohs(rh->rh_seqno) <= tfwc_sndr_.magic() + tfwc_sndr_.jacked()) {
- //debug_msg("cwnd: %d\n", tfwc_sndr_.magic());
- //debug_msg("jack: %d\n", tfwc_sndr_.jacked());
+ debug_msg("cwnd: %d\n", tfwc_sndr_.magic());
+ debug_msg("jack: %d\n", tfwc_sndr_.jacked());
// move head pointer
head_ = pb->next;
// call Transmitter::output_data_only w/ XR reception
output_data_only(pb, ack_clock);
- if (head_ != 0)
+ if (head_ != 0) {
pb = head_;
- else
+ rh = (rtphdr *) pb->data;
+ } else
break;
}
}
@@ -390,7 +422,7 @@
}
/*
- * main TFWC CC output routines
+ * main TFWC CC output routines (called when buff_is_empty)
*/
void Transmitter::tfwc_output(bool ack_clock)
{
@@ -413,11 +445,11 @@
{
int len = 0;
// cwnd (in bytes)
- int b_magic = tfwc_sndr_.b_magic();
+ //int b_magic = tfwc_sndr_.b_magic();
// see if any XR has arrived to pick up
int cc = check_xr_arrival(pb, 1);
- while(pb->len <= b_magic + cc - len) {
+ while(pb->len <= tfwc_sndr_.b_magic() + cc - len) {
len += pb->len;
// move head pointer
head_ = pb->next;
@@ -442,8 +474,8 @@
// while packet seqno is within "cwnd + jack", send that packet
while (ntohs(rh->rh_seqno) <= tfwc_sndr_.magic() + tfwc_sndr_.jacked()) {
- //debug_msg("cwnd: %d\n", tfwc_sndr_.magic());
- //debug_msg("jack: %d\n", tfwc_sndr_.jacked());
+ debug_msg("cwnd: %d\n", tfwc_sndr_.magic());
+ debug_msg("jack: %d\n", tfwc_sndr_.jacked());
// move head pointer
head_ = pb->next;
@@ -473,7 +505,7 @@
// by SessionManager::recv(CtrlHandler* ch).
// therefore, assign pktbuf's head to pb.
if (pb == 0)
- pb = head_;
+ pb = head_;
// if pb is null here, it means the actual pkbuf is empty!
if (pb == 0) {
@@ -493,8 +525,10 @@
}
/*
- * main TFRC CC output
+ * main TFRC CC output NOT USED - pkts sent in timeout()
+ * ~~~~~~~~
*/
+// main TFRC CC output routine (called when NOT buff_is_empty)
void Transmitter::tfrc_output(pktbuf* pb) {
cc_output_banner_top("tfrc");
// move head pointer
@@ -505,6 +539,7 @@
cc_output_banner_bottom();
}
+// main TFRC CC output routine (called when buff_is_empty)
void Transmitter::tfrc_output(bool ack_clock) {
cc_output_banner_top("tfrc");
// head of the RTP data packet buffer
@@ -520,7 +555,7 @@
// move head pointer
head_ = pb->next;
// call Transmitter::output(pb)
- output(pb, ack_clock);
+ output(pb, ack_clock); // BUG? This just calls net->send()....??? Piers
cc_output_banner_bottom();
}
@@ -528,24 +563,28 @@
{
double now = gettimeofday_secs();
+ debug_msg("Timeout: nextpkttime_: %f, now: %f \n",nextpkttime_, now);
switch (cc_type_) {
- case RBCC:
+ /*case RBCC:
for (;;) {
pktbuf* p = head_;
if(p != 0) {
+ head_ = p->next;
nextpkttime_ += txtime(p);
// call send(pktbuf *) here
- send(p);
+ //send(p);
+ output(p);
// goto sleep
int ms = int(1e-3 * (nextpkttime_ - now));
msched(ms);
}
}
- break;
+ break;*/
case WBCC:
// nothing to do when WBCC mode
break;
case NOCC:
+ case RBCC:
default:
for (;;) {
pktbuf* p = head_;
@@ -553,13 +592,15 @@
head_ = p->next;
nextpkttime_ += txtime(p);
output(p);
- int ms = int(1e-3 * (nextpkttime_ - now));
+ int ms = int(1e3 * (nextpkttime_ - gettimeofday_secs()));
+ debug_msg("Timeout: Sent packet, delay till next send: %d, nextpkttime_: %f, now: %f\n",ms,nextpkttime_, now);
/* make sure we will wait more than 10ms */
if (ms > 1000) {
msched(ms);
return;
}
} else {
+ debug_msg("Timeout: Send Q empty\n");
busy_ = 0;
break;
}
@@ -585,17 +626,20 @@
}
}
+// Transmit RTP and DO send AoA
void Transmitter::output(pktbuf* pb, bool ack_clock)
{
//fprintf(stderr, "\n\tTransmitter::output()\n");
//if (dumpfd_ >= 0)
// dump(dumpfd_, pb->iov, mh_.msg_iovlen);
//dprintf("layer: %d \n",pb->layer);
+//SessionManager::transmit()
transmit(pb, ack_clock);
loopback(pb);
// pb->release() is called by decoder in loopback;
}
+// Transmit RTP and DO NOT send AoA
void Transmitter::output_data_only(pktbuf* pb, bool flag)
{
tx_data_only(pb, flag);
Modified: vic/branches/cc/rtp/transmitter.h
==============================================================================
--- vic/branches/cc/rtp/transmitter.h (original)
+++ vic/branches/cc/rtp/transmitter.h Tue Oct 25 16:06:21 2011
@@ -62,6 +62,11 @@
#define PKM 1 // PacKet Mode
#define BYM 2 // BYtes Mode
+//ecn_mode settings
+#define ECN_AS_LOSS 0
+#define ECN_IGNORE 1
+#define ECN_ACTION 2
+
class TfwcSndr;
class TfwcRcvr;
class TfrcSndr;
@@ -93,7 +98,7 @@
};*/
static void dump(int fd);
static inline void seqno(u_int16_t s) { seqno_ = s; }
- inline void bps(int kbps) { kbps = kbps_; }
+ inline void bps(int kbps) { kbps_ = kbps; }
inline void loop_layer(int loop_layer) { loop_layer_ = loop_layer; }
inline int loop_layer() { return loop_layer_; }
inline int mtu() { return (mtu_); }
@@ -175,6 +180,7 @@
int loop_layer_; /* # of layers to loop back (for testing) */
int loopback_; /* true to loopback data packets */
+ int ecn_mode_; /* true to loopback data packets */
static int dumpfd_; /* fd to dump packet stream to */
static u_int16_t seqno_;
Modified: vic/branches/cc/tcl/ui-ctrlmenu.tcl
==============================================================================
--- vic/branches/cc/tcl/ui-ctrlmenu.tcl (original)
+++ vic/branches/cc/tcl/ui-ctrlmenu.tcl Tue Oct 25 16:06:21 2011
@@ -170,6 +170,22 @@
if [have_transmit_permission] {
selectInitialDevice
}
+
+ set f [resource stillFile]
+ if { $f != "" } {
+ global lastDevice
+ if { [$lastDevice nickname] == "still" } {
+ $lastDevice file $f
+ }
+ }
+
+ set f [resource fileGrabberFile]
+ if { $f != "" } {
+ global lastDevice
+ if { [$lastDevice nickname] == "filegrab" } {
+ $lastDevice file $f
+ }
+ }
}
proc defaultDevice {} {
@@ -218,8 +234,7 @@
}
}
foreach v $inputDeviceList {
- if { "[$v attributes]" != "disabled" &&
- "[$v nickname]" != "still" } {
+ if { "[$v attributes]" != "disabled" } {
set videoDevice $v
select_device $v
return
@@ -430,6 +445,10 @@
$V(grabber) q $grabq
}
}
+
+ # Inform sessionmanager of grabber so it can control grabber bps - piers
+ session grabber $V(grabber)
+
if [have capwin] {
set w [winfo toplevel $V(capwin)]
if $transmitButtonState {
@@ -546,7 +565,7 @@
#XXX
session data-bandwidth $value
}
- $w configure -text "$value bps"
+ $w configure -text "$value Kbps"
}
proc set_fps { w value } {
@@ -829,10 +848,6 @@
return
}
foreach d $inputDeviceList {
- if { [$d nickname] == "still" && ![yesno stillGrabber] } {
- # set defaultFormat($d) $videoFormat
- # continue
- }
# this is fragile
$m add radiobutton -label [$d nickname] \
-command "select_device $d" \
Modified: vic/branches/cc/tcl/ui-grabber.tcl
==============================================================================
--- vic/branches/cc/tcl/ui-grabber.tcl (original)
+++ vic/branches/cc/tcl/ui-grabber.tcl Tue Oct 25 16:06:21 2011
@@ -681,13 +681,13 @@
proc build.still w {
set f [smallfont]
- label $w.title -text "Grabber"
+ label $w.title -text "Still Grabber"
frame $w.f -relief sunken -borderwidth 2
label $w.f.label -font $f -anchor e -text "File"
- mk.entry $w.f set.still.frame "frame"
+ mk.entry $w.f set.file.frame [resource stillFile]
pack $w.title $w.f -fill x -expand 1
@@ -695,14 +695,14 @@
pack $w.f.entry -side left -fill x -expand 1
}
-proc build.stilldev w {
+proc build.filegrab w {
set f [smallfont]
- label $w.title -text "FileGrabber"
+ label $w.title -text "File Grabber"
frame $w.f -relief sunken -borderwidth 2
label $w.f.label -font $f -anchor e -text "File"
- mk.entry $w.f set.still.frame "frame"
+ mk.entry $w.f set.file.frame [resource fileGrabberFile]
pack $w.title $w.f -fill x -expand 1
@@ -710,7 +710,7 @@
pack $w.f.entry -side left -fill x -expand 1
}
-proc set.still.frame {w s } {
+proc set.file.frame {w s } {
global lastDevice
$lastDevice file $s
}
Modified: vic/branches/cc/tcl/ui-main.tcl
==============================================================================
--- vic/branches/cc/tcl/ui-main.tcl (original)
+++ vic/branches/cc/tcl/ui-main.tcl Tue Oct 25 16:06:21 2011
@@ -105,8 +105,8 @@
-command "ag_autoplace::show_ui"
}
- pack $w.bar.title -side left -fill both -expand 1
- pack $w.bar.menu $w.bar.autoplace $w.bar.help $w.bar.quit -side left -padx 1 -pady 1
+ pack $w.bar.title -side top -fill both -expand 1 -anchor center
+ pack $w.bar.menu $w.bar.autoplace $w.bar.help $w.bar.quit -side left -padx 1 -pady 1 -anchor center
if {[windowingsystem] == "aqua"} {
label $w.bar.gap -text " "
@@ -770,15 +770,14 @@
$decoder maxChannel $numLayers
}
# Inform decoder obj of grabber to enable PSNR calculation
- if { [$videoDevice nickname] == "still" } {
+ if { [$videoDevice nickname] == "filegrab" } {
if ![have grabber] {
+ #Create filedev grabber obj so decoder can be informed of it
set V(grabber) [$videoDevice open cif]
if { $V(grabber) != "" } {
- puts "ssspam"
$decoder grabber $V(grabber)
}
} else {
- puts "spam"
$decoder grabber $V(grabber)
}
}
Modified: vic/branches/cc/tcl/ui-resource.tcl
==============================================================================
--- vic/branches/cc/tcl/ui-resource.tcl (original)
+++ vic/branches/cc/tcl/ui-resource.tcl Tue Oct 25 16:06:21 2011
@@ -178,8 +178,10 @@
option add Vic.infoHighlightColor LightYellow2 startupFile
option add Vic.useJPEGforH261 false startupFile
option add Vic.useHardwareComp false startupFile
- option add Vic.stillGrabber false startupFile
+ option add Vic.stillGrabber true startupFile
+ option add Vic.stillFile "" startupFile
option add Vic.fileGrabber true startupFile
+ option add Vic.fileGrabberFile "" startupFile
option add Vic.siteDropTime "300" startupFile
option add Vic.quality "0" startupFile
option add Vic.inputType "ntsc" startupFile
Copied: vic/branches/cc/video/grabber-file.cpp (from r4901, /vic/branches/cc/video/grabber-still.cpp)
==============================================================================
--- /vic/branches/cc/video/grabber-still.cpp (original)
+++ vic/branches/cc/video/grabber-file.cpp Tue Oct 25 16:06:21 2011
@@ -1,5 +1,9 @@
/*
- * Copyright (c) 1993-1995 Regents of the University of California.
+ * FILE: grabber-file.cpp
+ * AUTHOR: Soo-Hyun Choi <s.choi at cs.ucl.ac.uk>
+ * Piers O'Hanlon <p.ohanlon at cs.ucl.ac.uk>
+ *
+ * Copyright (c) 2011 University College London
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,31 +14,22 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and the Network Research Group at
- * Lawrence Berkeley Laboratory.
- * 4. Neither the name of the University nor of the Laboratory may be used
- * to endorse or promote products derived from this software without
- * specific prior written permission.
+ * 3. Neither the names of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+ * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*
- * Contributed by Bob Olson (olson at mcs.anl.gov) September 1995.
- */
-
-/*
* $Id$
*/
@@ -60,13 +55,10 @@
#include "transmitter.h"
#include "module.h"
-//#define DEBUG 1
-#undef DEBUG
-
-class StillGrabber : public Grabber {
+class FileGrabber : public Grabber {
public:
- StillGrabber();
- virtual ~StillGrabber();
+ FileGrabber();
+ virtual ~FileGrabber();
virtual int command(int argc, const char* const * argv);
protected:
void start();
@@ -74,10 +66,10 @@
int grab();
};
-class StillYuvGrabber : public StillGrabber {
+class FileYuvGrabber : public FileGrabber {
public:
- StillYuvGrabber();
- virtual ~StillYuvGrabber();
+ FileYuvGrabber();
+ virtual ~FileYuvGrabber();
virtual int command(int argc, const char* const* argv);
protected:
@@ -95,9 +87,9 @@
double ini_ftime_; // initial frametime
};
-class StillDevice : public InputDevice {
+class FileDevice : public InputDevice {
public:
- StillDevice(const char* s);
+ FileDevice(const char* s);
virtual int command(int argc, const char * const * argv);
virtual Grabber* jpeg_grabber();
virtual Grabber* yuv_grabber();
@@ -110,26 +102,26 @@
private:
};
-static StillDevice still_device("still");
+static FileDevice filegrab_device("filegrab");
-StillDevice::StillDevice(const char* s) : InputDevice(s),
+FileDevice::FileDevice(const char* s) : InputDevice(s),
frame_(NULL), len_(0), devstat_(-1)
{
- attributes_ = "format { 411 422 jpeg cif } size { small large cif }";
+ attributes_ = "format { 411 cif } size { small large cif }";
#ifdef DEBUG
- debug_msg("StillDevice::StillDevice name=%s\n", s);
+ debug_msg("FileDevice::FileDevice name=%s\n", s);
#endif /* DEBUG */
}
/*
- * StillDevice
+ * FileDevice
*/
-int StillDevice::command(int argc, const char*const* argv)
+int FileDevice::command(int argc, const char*const* argv)
{
#ifdef DEBUG
for (int i = 0; i < argc; i++)
- debug_msg("StillDevice\t%s\n", argv[i]);
+ debug_msg("FileDevice\t%s\n", argv[i]);
#endif
if (argc == 3)
{
@@ -153,22 +145,23 @@
{
debug_msg("Loading %s\n", argv[2]);
load_file(argv[2]);
+ return (TCL_OK);
}
}
return (InputDevice::command(argc, argv));
}
-Grabber* StillDevice::jpeg_grabber()
+Grabber* FileDevice::jpeg_grabber()
{
- return (new StillGrabber());
+ return (new FileGrabber());
}
-Grabber* StillDevice::yuv_grabber()
+Grabber* FileDevice::yuv_grabber()
{
- return (new StillYuvGrabber());
+ return (new FileYuvGrabber());
}
-void StillDevice::load_file(const char * const f)
+void FileDevice::load_file(const char * const f)
{
FILE *fp;
struct stat s;
@@ -187,26 +180,29 @@
return;
}
- len_ = s.st_size;
+ len_ = s.st_size; // file length
+ if (len_ == 0) return;
+
if (frame_)
delete[] frame_; //SV-XXX: Debian
- frame_ = new u_char[len_ + 1];
- r = fread(frame_, len_, 1, fp);
- fprintf(stderr,"Successfully loaded %s\n", f);
- devstat_ = 0; // device is now ready
+ frame_ = new u_char[len_ + 1];
+ fread(frame_, len_, 1, fp);
+
+ debug_msg("Successfully loaded %s\n", f);
+ devstat_ = 0; // device is now ready
fclose(fp);
}
/*
- * StillGrabber
+ * FileGrabber
*/
-int StillGrabber::command(int argc, const char * const * argv)
+int FileGrabber::command(int argc, const char * const * argv)
{
//SV-XXX: unused: Tcl& tcl = Tcl::instance();
#ifdef DEBUG
- debug_msg("StillGrabber::command argc=%d\n", argc);
+ debug_msg("FileGrabber::command argc=%d\n", argc);
int i;
for (i = 0; i < argc; i++)
debug_msg("\"%s\"\n", argv[i]);
@@ -221,38 +217,38 @@
return (Grabber::command(argc, argv));
}
-StillGrabber::StillGrabber()
+FileGrabber::FileGrabber()
{
// set device status
- status_ = still_device.devstat_;
+ status_ = filegrab_device.devstat_;
}
-StillGrabber::~StillGrabber()
+FileGrabber::~FileGrabber()
{
#ifdef DEBUG
- debug_msg("Destroy StillGrabber\n");
+ debug_msg("Destroy FileGrabber\n");
#endif
}
-void StillGrabber::start()
+void FileGrabber::start()
{
Grabber::start();
}
-void StillGrabber::stop()
+void FileGrabber::stop()
{
cancel();
}
-int StillGrabber::grab()
+int FileGrabber::grab()
{
#ifdef DEBUG
- debug_msg("StillGrabber::grab() called\n");
+ debug_msg("FileGrabber::grab() called\n");
#endif
int frc=0; //SV-XXX: gcc4 warns for initialisation
- if (still_device.frame_) {
- JpegFrame f(media_ts(), (u_int8_t *) still_device.frame_,
- still_device.len_,
+ if (filegrab_device.frame_) {
+ JpegFrame f(media_ts(), (u_int8_t *) filegrab_device.frame_,
+ filegrab_device.len_,
80, 0, 320, 240);
frc = target_->consume(&f);
}
@@ -261,12 +257,12 @@
}
/*
- * StillYuvGraber
+ * FileYuvGraber
*/
-int StillYuvGrabber::command(int argc, const char* const* argv)
+int FileYuvGrabber::command(int argc, const char* const* argv)
{
#ifdef DEBUG
- debug_msg("StillYuvGrabber::command argc=%d\n", argc);
+ debug_msg("FileYuvGrabber::command argc=%d\n", argc);
for (int i = 0; i < argc; i++)
debug_msg("\"%s\"\n", argv[i]);
#endif
@@ -317,44 +313,44 @@
return (Grabber::command(argc, argv));
}
-StillYuvGrabber::StillYuvGrabber() :
+FileYuvGrabber::FileYuvGrabber() :
width_(0), height_(0), nbytes_(0)
{
grabber_ts_off_ = grabber_now();
- frame_=still_device.frame_;
- fprintf(stderr,"StillYuvGrabber::StillYuvGrabber:frame_:%x\n",frame_);
+ frame_=filegrab_device.frame_;
+ fprintf(stderr,"FileYuvGrabber::FileYuvGrabber:frame_:%x\n",frame_);
}
-StillYuvGrabber::~StillYuvGrabber()
+FileYuvGrabber::~FileYuvGrabber()
{
#ifdef DEBUG
- debug_msg("Destroy StillYuvGrabber\n");
+ debug_msg("Destroy FileYuvGrabber\n");
#endif
}
-void StillYuvGrabber::fps(int v) {
+void FileYuvGrabber::fps(int v) {
Grabber::fps(v);
ini_ftime_ = 1e6 / double(v);
}
-void StillYuvGrabber::start()
+void FileYuvGrabber::start()
{
target_->offset_ = grabber_ts_off_;
// XXX Need to change frame_ - it used for storage of video frame and (re)allocated elsewhere
- frame_=still_device.frame_;
- fprintf(stderr,"StillYuvGrabber::start:frame_:%x\n",frame_);
+ frame_=filegrab_device.frame_;
+ fprintf(stderr,"FileYuvGrabber::start:frame_:%x\n",frame_);
Grabber::start();
}
-void StillYuvGrabber::stop()
+void FileYuvGrabber::stop()
{
cancel();
}
-void StillYuvGrabber::setsize()
+void FileYuvGrabber::setsize()
{
#ifdef DEBUG
- debug_msg("StillYuvGrabber::setsize()\n");
+ debug_msg("FileYuvGrabber::setsize()\n");
#endif
if(running_)
@@ -369,20 +365,26 @@
allocref();
}
-int StillYuvGrabber::grab()
+int FileYuvGrabber::grab()
{
#ifdef DEBUG
- debug_msg("StillYuvGrabber::grab() called\n");
+ debug_msg("FileYuvGrabber::grab() called\n");
#endif
- int frc=0; //SV-XXX: gcc4 warns for initialisation
+ int frc=0; //SV-XXX: gcc4 warns for initialisation
+#ifdef SUSPEND_GRAB
// check if Tx queue is growing too much.
// if so, we should suspend grabbing more frames.
- if (target_->suspend_grabbing(5))
- return (frc);
+ if (target_->suspend_grabbing(5)){
+ if (fps_ > 0) fps(--fps_);
+ } else if (fps_ < 30) fps(++fps_);
+ //return (frc);
+ debug_msg("now: %f, fps_: %d\n", fps_);
+#endif
// time measurement
+ debug_msg("grab: fps %d, bps: %d\n", fps_, bps_);
start_grab_ = grabber_now() - grabber_ts_off_;
fprintf(stderr, "start_grab\tnow: %f\n", start_grab_);
@@ -392,11 +394,9 @@
int stride= framesize_ + (framesize_ >> 1);
int frame_no=nbytes_/stride;
fprintf(stderr,"Frame_no %d, number of bytes: %d (fsz:%d)\n",frame_no, nbytes_, framesize_);
- memcpy (frame_, still_device.frame_ + nbytes_,
- stride);
+ memcpy (frame_, filegrab_device.frame_ + nbytes_, stride);
- if ((nbytes_ += stride) < still_device.len_) {
- } else {
+ if ((nbytes_ += stride) >= filegrab_device.len_) {
nbytes_=0;
}
@@ -415,5 +415,5 @@
end_grab_, end_grab_ - start_grab_);
frc = target_->consume(&f);
- return frc;
+ return frc;
}
Modified: vic/branches/cc/video/grabber.cpp
==============================================================================
--- vic/branches/cc/video/grabber.cpp (original)
+++ vic/branches/cc/video/grabber.cpp Tue Oct 25 16:06:21 2011
@@ -208,21 +208,21 @@
*/
double Grabber::tick(int frameSize)
{
- double frametime = 8e6 * double(frameSize) / double(bps_); // uSecs
- if (frametime < frametime_) {
- if (frametime * 2. < frametime_)
- delta_ += (frametime - delta_) * .25;
+ double bpsframetime = 8e6 * double(frameSize) / double(bps_); // uSecs
+ if (bpsframetime < frametime_) {
+ if (bpsframetime * 2. < frametime_)
+ delta_ += (bpsframetime - delta_) * .25;
else
- delta_ = frametime;
- frametime = frametime_;
+ delta_ = bpsframetime;
+ bpsframetime = frametime_;
} else
- delta_ = frametime;
+ delta_ = bpsframetime;
- frameclock_ += frametime;
+ frameclock_ += bpsframetime;
double now = gettimeofday_usecs();
double delta = frameclock_ - now;
if (delta < -0.2e6) {
- delta = frametime;
+ delta = bpsframetime;
frameclock_ = now;
} else if (delta < 0)
/*
@@ -231,6 +231,7 @@
*/
delta = 0.;
+ debug_msg("tick(): now: %f delta: %f (delta_ %f) frametime_ %f frametime %f frameclock_ %f, frameSize :%d\n",now, delta, delta_, frametime_, bpsframetime, frameclock_, frameSize);
return (delta);
}
Modified: vic/branches/cc/video/grabber.h
==============================================================================
--- vic/branches/cc/video/grabber.h (original)
+++ vic/branches/cc/video/grabber.h Tue Oct 25 16:06:21 2011
@@ -127,7 +127,7 @@
int idle_low_;
int idle_high_;
- double frametime_; /* 1 / fps */
+ double frametime_; /* 1 / fps_ */
double frameclock_; /* logical clock for pumping out frames */
int fps_; /* desired frames per second */
More information about the Sumover-dev
mailing list