opalvoip-svn Mailing List for OpalVOIP (Page 10)
Brought to you by:
csoutheren,
rjongbloed
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(71) |
Nov
(241) |
Dec
(143) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(210) |
Feb
(263) |
Mar
(214) |
Apr
(290) |
May
(203) |
Jun
(160) |
Jul
(128) |
Aug
(158) |
Sep
(376) |
Oct
(234) |
Nov
(227) |
Dec
(216) |
2009 |
Jan
(99) |
Feb
(151) |
Mar
(234) |
Apr
(143) |
May
(271) |
Jun
(244) |
Jul
(173) |
Aug
(124) |
Sep
(246) |
Oct
(178) |
Nov
(85) |
Dec
(77) |
2010 |
Jan
(101) |
Feb
(79) |
Mar
(92) |
Apr
(134) |
May
(125) |
Jun
(121) |
Jul
(61) |
Aug
(70) |
Sep
(86) |
Oct
(81) |
Nov
(65) |
Dec
(75) |
2011 |
Jan
(110) |
Feb
(119) |
Mar
(267) |
Apr
(154) |
May
(296) |
Jun
(177) |
Jul
(149) |
Aug
(124) |
Sep
(120) |
Oct
(116) |
Nov
(99) |
Dec
(121) |
2012 |
Jan
(78) |
Feb
(161) |
Mar
(323) |
Apr
(154) |
May
(190) |
Jun
(207) |
Jul
(176) |
Aug
(165) |
Sep
(137) |
Oct
(85) |
Nov
(112) |
Dec
(100) |
2013 |
Jan
(341) |
Feb
(102) |
Mar
(240) |
Apr
(216) |
May
(233) |
Jun
(226) |
Jul
(139) |
Aug
(192) |
Sep
(183) |
Oct
(211) |
Nov
(220) |
Dec
(110) |
2014 |
Jan
(203) |
Feb
(205) |
Mar
(100) |
Apr
(178) |
May
(194) |
Jun
(249) |
Jul
(136) |
Aug
(241) |
Sep
(226) |
Oct
(200) |
Nov
(94) |
Dec
(46) |
2015 |
Jan
(94) |
Feb
(74) |
Mar
(89) |
Apr
(78) |
May
(65) |
Jun
(70) |
Jul
(113) |
Aug
(176) |
Sep
(140) |
Oct
(154) |
Nov
(99) |
Dec
(115) |
2016 |
Jan
(102) |
Feb
(69) |
Mar
(97) |
Apr
(53) |
May
(42) |
Jun
(13) |
Jul
(42) |
Aug
(30) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <rjo...@us...> - 2016-03-19 16:55:10
|
Revision: 34701 http://sourceforge.net/p/opalvoip/code/34701 Author: rjongbloed Date: 2016-03-19 16:55:07 +0000 (Sat, 19 Mar 2016) Log Message: ----------- Merged revision(s) 34699-34700 from opal/branches/v3_16: Make sure gatekeeper monitor thread exits quickly when asked to. Modified Paths: -------------- opal/trunk/src/h323/gkclient.cxx Property Changed: ---------------- opal/trunk/ Index: opal/trunk =================================================================== --- opal/trunk 2016-03-19 16:54:09 UTC (rev 34700) +++ opal/trunk 2016-03-19 16:55:07 UTC (rev 34701) Property changes on: opal/trunk ___________________________________________________________________ Modified: svn:mergeinfo ## -10,7 +10,7 ## /opal/branches/v3_10:25182-29485,30896,32927-32928,32933 /opal/branches/v3_12:28489-31709 /opal/branches/v3_14:31505-33613 -/opal/branches/v3_16:34090-34698 +/opal/branches/v3_16:34090-34700 /opal/branches/v3_2:21143,21220,21227,21253,21455 /opal/branches/v3_4:21060,21062,21088,21092,21111,21113,21115,21119,21143,21148,21151-21152,21155,21158,21184,21188,21253,21265-21266,21283-21284,21298,21300,21303,21307,21309,21311,21327,21331,21333,21359,21367,21369,21488,21556,21564-21565,21568,21570,21620,21625,21631,21748,21751,21756,21759,21761,21767,21770,22246,23044,23140,23143,23286 /opal/branches/v3_6:22169,22178,22184,22186,22197,22204,22216,22251,22253,22255,22258,22260,22291,22296,22300,22306,22308,22313,22319,22336,22353,22358,22436,22447,22449,22497,22511,22517,22519-22521,22527,22536,22538,22589,22596,22599,22617,22620,22622,22630,22640,22655,22675,22682,22726-22728,22730,22733,22738,22745-22746,22800,22820-22821,22842,22844-22845,22851,22853,22889,22896,22902,22904,22906,22918,22924,22928,22946,22965,22967,22976,22978,22980,22982,22994,23028,23123,23125-23126,23128,23157,23165,23173,23175,23183,23294,23341,23465,23467,23474,23521,23829,24346,24809 \ No newline at end of property Modified: opal/trunk/src/h323/gkclient.cxx =================================================================== --- opal/trunk/src/h323/gkclient.cxx 2016-03-19 16:54:09 UTC (rev 34700) +++ opal/trunk/src/h323/gkclient.cxx 2016-03-19 16:55:07 UTC (rev 34701) @@ -846,6 +846,8 @@ waitTime = irrTimer.GetRemaining(); m_monitorTickle.Wait(waitTime); + if (!m_monitorRunning) + break; if (m_forceRegister || (m_currentTimeToLive > 0 && ttlTimer.HasExpired())) ttlTimer = InternalRegister(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-19 16:54:11
|
Revision: 34700 http://sourceforge.net/p/opalvoip/code/34700 Author: rjongbloed Date: 2016-03-19 16:54:09 +0000 (Sat, 19 Mar 2016) Log Message: ----------- Make sure gatekeeper monitor thread exits quickly when asked to. Modified Paths: -------------- opal/branches/v3_16/src/h323/gkclient.cxx Modified: opal/branches/v3_16/src/h323/gkclient.cxx =================================================================== --- opal/branches/v3_16/src/h323/gkclient.cxx 2016-03-19 15:26:03 UTC (rev 34699) +++ opal/branches/v3_16/src/h323/gkclient.cxx 2016-03-19 16:54:09 UTC (rev 34700) @@ -804,6 +804,8 @@ waitTime = irrTimer.GetRemaining(); m_monitorTickle.Wait(waitTime); + if (!m_monitorRunning) + break; if (m_forceRegister || (m_currentTimeToLive > 0 && ttlTimer.HasExpired())) ttlTimer = InternalRegister(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-19 15:26:05
|
Revision: 34699 http://sourceforge.net/p/opalvoip/code/34699 Author: rjongbloed Date: 2016-03-19 15:26:03 +0000 (Sat, 19 Mar 2016) Log Message: ----------- Merged revision(s) 34682-34698 from opal/branches/v3_16: Fixed binding H.245 listener socket to correct local interface address when NAT is in use. Modified Paths: -------------- opal/trunk/src/h323/h323.cxx Property Changed: ---------------- opal/trunk/ Index: opal/trunk =================================================================== --- opal/trunk 2016-03-19 15:23:52 UTC (rev 34698) +++ opal/trunk 2016-03-19 15:26:03 UTC (rev 34699) Property changes on: opal/trunk ___________________________________________________________________ Modified: svn:mergeinfo ## -10,7 +10,7 ## /opal/branches/v3_10:25182-29485,30896,32927-32928,32933 /opal/branches/v3_12:28489-31709 /opal/branches/v3_14:31505-33613 -/opal/branches/v3_16:34090-34681 +/opal/branches/v3_16:34090-34698 /opal/branches/v3_2:21143,21220,21227,21253,21455 /opal/branches/v3_4:21060,21062,21088,21092,21111,21113,21115,21119,21143,21148,21151-21152,21155,21158,21184,21188,21253,21265-21266,21283-21284,21298,21300,21303,21307,21309,21311,21327,21331,21333,21359,21367,21369,21488,21556,21564-21565,21568,21570,21620,21625,21631,21748,21751,21756,21759,21761,21767,21770,22246,23044,23140,23143,23286 /opal/branches/v3_6:22169,22178,22184,22186,22197,22204,22216,22251,22253,22255,22258,22260,22291,22296,22300,22306,22308,22313,22319,22336,22353,22358,22436,22447,22449,22497,22511,22517,22519-22521,22527,22536,22538,22589,22596,22599,22617,22620,22622,22630,22640,22655,22675,22682,22726-22728,22730,22733,22738,22745-22746,22800,22820-22821,22842,22844-22845,22851,22853,22889,22896,22902,22904,22906,22918,22924,22928,22946,22965,22967,22976,22978,22980,22982,22994,23028,23123,23125-23126,23128,23157,23165,23173,23175,23183,23294,23341,23465,23467,23474,23521,23829,24346,24809 \ No newline at end of property Modified: opal/trunk/src/h323/h323.cxx =================================================================== --- opal/trunk/src/h323/h323.cxx 2016-03-19 15:23:52 UTC (rev 34698) +++ opal/trunk/src/h323/h323.cxx 2016-03-19 15:26:03 UTC (rev 34699) @@ -2862,7 +2862,8 @@ } if (controlListener == NULL) { - controlListener = m_signallingChannel->GetLocalAddress().CreateListener(endpoint, OpalTransportAddress::HostOnly); + OpalTransportAddress addr(m_signallingChannel->GetInterface(), 0, m_signallingChannel->GetLocalAddress().GetProto()); + controlListener = addr.CreateListener(endpoint, OpalTransportAddress::HostOnly); if (controlListener == NULL) return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-19 15:23:54
|
Revision: 34698 http://sourceforge.net/p/opalvoip/code/34698 Author: rjongbloed Date: 2016-03-19 15:23:52 +0000 (Sat, 19 Mar 2016) Log Message: ----------- Fixed binding H.245 listener socket to correct local interface address when NAT is in use. Modified Paths: -------------- opal/branches/v3_16/src/h323/h323.cxx Modified: opal/branches/v3_16/src/h323/h323.cxx =================================================================== --- opal/branches/v3_16/src/h323/h323.cxx 2016-03-19 15:11:45 UTC (rev 34697) +++ opal/branches/v3_16/src/h323/h323.cxx 2016-03-19 15:23:52 UTC (rev 34698) @@ -2695,7 +2695,8 @@ } if (controlListener == NULL) { - controlListener = m_signallingChannel->GetLocalAddress().CreateListener(endpoint, OpalTransportAddress::HostOnly); + OpalTransportAddress addr(m_signallingChannel->GetInterface(), 0, m_signallingChannel->GetLocalAddress().GetProto()); + controlListener = addr.CreateListener(endpoint, OpalTransportAddress::HostOnly); if (controlListener == NULL) return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-19 15:11:47
|
Revision: 34697 http://sourceforge.net/p/opalvoip/code/34697 Author: rjongbloed Date: 2016-03-19 15:11:45 +0000 (Sat, 19 Mar 2016) Log Message: ----------- Merged revision(s) 34684-34696 from ptlib/branches/v2_16: Applied variant of patch #324 "Fix vxml record m_recordStopOnDTMF always set to true", thanks MichaelT Modified Paths: -------------- ptlib/trunk/src/ptclib/vxml.cxx Property Changed: ---------------- ptlib/trunk/ Index: ptlib/trunk =================================================================== --- ptlib/trunk 2016-03-19 15:09:41 UTC (rev 34696) +++ ptlib/trunk 2016-03-19 15:11:45 UTC (rev 34697) Property changes on: ptlib/trunk ___________________________________________________________________ Modified: svn:mergeinfo ## -6,7 +6,7 ## /ptlib/branches/v2_10:25177-29189,32921,32947 /ptlib/branches/v2_12:28485-31603 /ptlib/branches/v2_14:31501-33720 -/ptlib/branches/v2_16:34085-34683 +/ptlib/branches/v2_16:34085-34696 /ptlib/branches/v2_2:20746,20791,20827,22014,22942 /ptlib/branches/v2_4:21086,21094,21147,21160,21185,21281,21296,21305,21322,21337,21363,21467,21471-21472,21506,21508,21623,21695,21744,21746,21763,22241,22958,23045-23046,23061,23066,23712 /ptlib/branches/v2_6:22195,22243,22295,22304,22311,22317,22320,22356,22458,22509,22587,22601-22602,22611,22629,22633,22673,22681,22729,22731-22732,22736,22742,22848,22960,22992,23161,23163,23167,23169,23177,23239,23291,23298,23336,23429,23595,23823,23827,23873,24816 \ No newline at end of property Modified: ptlib/trunk/src/ptclib/vxml.cxx =================================================================== --- ptlib/trunk/src/ptclib/vxml.cxx 2016-03-19 15:09:41 UTC (rev 34696) +++ ptlib/trunk/src/ptclib/vxml.cxx 2016-03-19 15:11:45 UTC (rev 34697) @@ -1484,7 +1484,8 @@ SetVar(m_recordingName + "$.size", '0'); } - m_recordStopOnDTMF = element.HasAttribute("dtmfterm")|| !(element.GetAttribute("dtmfterm") *= "false"); + // Disable stop on DTMF if attribute explicitly false, default is true + m_recordStopOnDTMF = !(element.GetAttribute("dtmfterm") *= "false"); PFile::Remove(destination); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-19 15:09:44
|
Revision: 34696 http://sourceforge.net/p/opalvoip/code/34696 Author: rjongbloed Date: 2016-03-19 15:09:41 +0000 (Sat, 19 Mar 2016) Log Message: ----------- Applied variant of patch #324 "Fix vxml record m_recordStopOnDTMF always set to true", thanks MichaelT Modified Paths: -------------- ptlib/branches/v2_16/src/ptclib/vxml.cxx Modified: ptlib/branches/v2_16/src/ptclib/vxml.cxx =================================================================== --- ptlib/branches/v2_16/src/ptclib/vxml.cxx 2016-03-18 18:41:36 UTC (rev 34695) +++ ptlib/branches/v2_16/src/ptclib/vxml.cxx 2016-03-19 15:09:41 UTC (rev 34696) @@ -1484,7 +1484,8 @@ SetVar(m_recordingName + "$.size", '0'); } - m_recordStopOnDTMF = element.HasAttribute("dtmfterm")|| !(element.GetAttribute("dtmfterm") *= "false"); + // Disable stop on DTMF if attribute explicitly false, default is true + m_recordStopOnDTMF = !(element.GetAttribute("dtmfterm") *= "false"); PFile::Remove(destination); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-18 18:41:39
|
Revision: 34695 http://sourceforge.net/p/opalvoip/code/34695 Author: rjongbloed Date: 2016-03-18 18:41:36 +0000 (Fri, 18 Mar 2016) Log Message: ----------- Fixed GNU warning Modified Paths: -------------- opal/trunk/src/codec/opusmf.cxx Modified: opal/trunk/src/codec/opusmf.cxx =================================================================== --- opal/trunk/src/codec/opusmf.cxx 2016-03-18 18:33:26 UTC (rev 34694) +++ opal/trunk/src/codec/opusmf.cxx 2016-03-18 18:41:36 UTC (rev 34695) @@ -165,7 +165,7 @@ PINDEX frameCount; - static unsigned const MaxFrames = 6; + static PINDEX const MaxFrames = 6; const BYTE * framePtr[MaxFrames]; switch (toc & 0x3) { case 0: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-18 18:33:28
|
Revision: 34694 http://sourceforge.net/p/opalvoip/code/34694 Author: rjongbloed Date: 2016-03-18 18:33:26 +0000 (Fri, 18 Mar 2016) Log Message: ----------- Removed now non-existant video rate control source form *nix build. Modified Paths: -------------- opal/trunk/make/toplevel.mak Modified: opal/trunk/make/toplevel.mak =================================================================== --- opal/trunk/make/toplevel.mak 2016-03-18 18:05:26 UTC (rev 34693) +++ opal/trunk/make/toplevel.mak 2016-03-18 18:33:26 UTC (rev 34694) @@ -427,8 +427,7 @@ $(OPAL_SRCDIR)/codec/rfc2833.cxx \ $(OPAL_SRCDIR)/codec/opalwavfile.cxx \ $(OPAL_SRCDIR)/codec/silencedetect.cxx \ - $(OPAL_SRCDIR)/codec/opalpluginmgr.cxx \ - $(OPAL_SRCDIR)/codec/ratectl.cxx + $(OPAL_SRCDIR)/codec/opalpluginmgr.cxx ifeq ($(OPAL_VIDEO), yes) SOURCES += $(OPAL_SRCDIR)/codec/vidcodec.cxx \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-18 18:05:29
|
Revision: 34693 http://sourceforge.net/p/opalvoip/code/34693 Author: rjongbloed Date: 2016-03-18 18:05:26 +0000 (Fri, 18 Mar 2016) Log Message: ----------- Remove old, unused, video rate control sub-system. Added frame dropping algorithm if underlying video encoder is unable to maintain the target bit rate. This can occur if a) the temporal/spatial trade off prevents the video encoder from reducing quality any further, so bit rate necessarily goes up, or b) the encoders bit rate control isn't very good. Modified Paths: -------------- opal/trunk/include/codec/vidcodec.h opal/trunk/include/opal/mediafmt.h opal/trunk/include/opal/mediasession.h opal/trunk/include/opal/patch.h opal/trunk/plugins/video/VP8-WebM/vp8_webm_2013.vcxproj opal/trunk/samples/codectest/main.cxx opal/trunk/samples/codectest/main.h opal/trunk/src/codec/opalpluginmgr.cxx opal/trunk/src/codec/vidcodec.cxx opal/trunk/src/opal/mediafmt.cxx opal/trunk/src/opal/mediasession.cxx opal/trunk/src/opal/patch.cxx opal/trunk/src/win32/dllmain.cxx opal/trunk/src/win32/opal_lib_2013.vcxproj opal/trunk/src/win32/opal_lib_2013.vcxproj.filters Removed Paths: ------------- opal/trunk/include/codec/ratectl.h opal/trunk/src/codec/ratectl.cxx Deleted: opal/trunk/include/codec/ratectl.h =================================================================== --- opal/trunk/include/codec/ratectl.h 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/include/codec/ratectl.h 2016-03-18 18:05:26 UTC (rev 34693) @@ -1,235 +0,0 @@ -/* - * ratectl.h - * - * Video rate controller - * - * Open Phone Abstraction Library (OPAL) - * - * Copyright (C) 2007 Matthias Schneider - * Copyright (C) 2008 Post Increment - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Open Phone Abstraction Library. - * - * The Initial Developer of the Original Code is Matthias Schneider - * - * Contributor(s): Post Increment - * - * $Revision$ - * $Author$ - * $Date$ - */ - -#ifndef OPAL_RATE_CONTROL_H -#define OPAL_RATE_CONTROL_H - -#ifdef P_USE_PRAGMA -#pragma interface -#endif - -#include <opal_config.h> - -#if OPAL_VIDEO - -#include <rtp/rtp.h> - -#include <deque> - -extern double OpalCalcSNR(const BYTE * src1, const BYTE * src2, PINDEX dataLen); - -/** This class is used to calculate the instantaneous bit rate of a data stream - * using a one second sliding window - */ - -class OpalBitRateCalculator -{ - public: - /** Create the calculator - */ - OpalBitRateCalculator(); - - /** Reset the statistics - */ - void Reset(); - - /** Set the quanta (usually the frame time) - */ - void SetQuanta( - unsigned quanta_ - ); - - /** Get the quanta (usually the frame time) - */ - unsigned GetQuanta() const - { return m_quanta; } - - /** Add a new packet to the bit rate calculations - */ - void AddPacket(PINDEX size, bool marker); - - /** Get the instantaneous bit rate - */ - unsigned GetBitRate(); - - /** Get the average bit rate since SetQuanta was called - */ - unsigned GetAverageBitRate(); - - /** Get the average bit rate since SetQuanta was called - */ - unsigned GetAveragePacketSize(); - - /** return the bit rate if the specific data size was transmitted - */ - unsigned GetTrialBitRate(PINDEX size); - - /** Return total bytes sent since SetQuanta was called - */ - PInt64 GetTotalSize() const; - - /** Return total miliseconds since SetQuanta was called - */ - PInt64 GetTotalTime() const; - - /** Return number of frames in history - */ - size_t GetHistoryCount() const - { return m_history.size(); } - - /** Return number of bytes in history - */ - unsigned GetHistorySize() const - { return m_historySize; } - - /** Return earlist timestamp in history - */ - PInt64 GetEarliestHistoryTime() const - { if (m_history.size() == 0) return 0; return m_history.begin()->m_timeStamp; } - - /** Return number of marker bits in history - */ - unsigned GetHistoryFrames() const; - - // flush old data from history - void Flush(); - - // used to get "now" - static PInt64 GetNow(); - - protected: - - void Flush(PInt64 now); - - struct History { - History(PINDEX size_, PInt64 timeStamp_, bool marker_) - : m_size(size_), m_timeStamp(timeStamp_), m_marker(marker_) - { } - - PINDEX m_size; - PInt64 m_timeStamp; - bool m_marker; - }; - - std::deque<History> m_history; - - PINDEX m_historySize; - PInt64 m_totalSize; - PINDEX m_historyFrames; - - unsigned m_quanta; - unsigned m_bitRate; - bool m_first; - PInt64 m_baseTimeStamp; -}; - -// -// Declare a generic video rate controller class. -// A rate controller seeks to maintain a constant bit rate by manipulating -// the parameters of the video stream -// -// Before encoding a potential output frame, use the SkipFrame function to determine if the -// frame should be skipped. -// -// If the frame is not skipped, encode the frame and call PushFrame to add the frame to the rate controller queue -// PopFrame can then be called to retreive frames to transmit -// -// PushFrame must always be called with packets from a single video frame, but PopFrame may return packets -// from multiple video frames -// - -class OpalMediaFormat; - -class OpalVideoRateController -{ - public: - OpalVideoRateController(); - - virtual ~OpalVideoRateController(); - - /** Open the rate controller with the specific parameters - */ - virtual void Open( - const OpalMediaFormat & mediaFormat - ); - - /** Determine if the next frame should be skipped. - * The rate controller can also indicate whether the next frame should - * be encoded as an I-frame, which is useful if many frames have been skipped - */ - virtual bool SkipFrame( - bool & forceIFrame - ) = 0; - - /** push encoded frames into the rate controller queue - */ - virtual void Push( - RTP_DataFrameList & inputFrames, - bool iFrame - ); - - /** retreive encoded frames from the rate controller queue - */ - virtual bool Pop( - RTP_DataFrameList & outputPackets, - bool & iFrame, - bool force - ); - - /** Bit rate calculator used by rate controller - */ - OpalBitRateCalculator m_bitRateCalc; - - protected: - unsigned m_targetBitRate; - unsigned m_outputFrameTime; - PInt64 m_inputFrameCount; - PInt64 m_outputFrameCount; - - struct PacketEntry { - PacketEntry(RTP_DataFrame * rtp_, bool iFrame_) - : m_rtp(rtp_), m_iFrame(iFrame_) - { } - - RTP_DataFrame * m_rtp; - bool m_iFrame; - }; - std::deque<PacketEntry> m_packets; -}; - -namespace PWLibStupidLinkerHacks { - extern int rateControlKickerVal; -// static class RateControlKicker { public: RateControlKicker() { rateControlKickerVal = 1; } } rateControlKicker; -}; - -#endif // OPAL_VIDEO - -#endif // OPAL_RATE_CONTROL_H Modified: opal/trunk/include/codec/vidcodec.h =================================================================== --- opal/trunk/include/codec/vidcodec.h 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/include/codec/vidcodec.h 2016-03-18 18:05:26 UTC (rev 34693) @@ -161,6 +161,10 @@ /**@name Operations */ //@{ +#if OPAL_STATISTICS + virtual void GetStatistics(OpalMediaStatistics & statistics) const; +#endif + /**Update the input and output media formats. This can be used to adjust the parameters of a codec at run time. Note you cannot change the basic media format, eg change GSM0610 to G.711, only options for that @@ -219,6 +223,10 @@ virtual bool HasErrorConcealment() const { return m_errorConcealment; } + + virtual bool ShouldDropFrame(RTP_Timestamp ts); + virtual void UpdateFrameDrop(const RTP_DataFrameList & encoded); + bool WasLastFrameIFrame() const { return m_lastFrameWasIFrame; } virtual void SendIFrameRequest(unsigned sequenceNumber, unsigned timestamp); virtual bool HandleIFrameRequest(); @@ -246,6 +254,12 @@ bool m_frozenTillIFrame; bool m_lastFrameWasIFrame; + RTP_Timestamp m_frameDropPeriod; + unsigned m_frameDropRate; + unsigned m_frameDropBits; + RTP_Timestamp m_lastTimestamp; + unsigned m_framesDropped; + OpalIntraFrameControl m_encodingIntraFrameControl; OpalIntraFrameControl m_decodingIntraFrameControl; }; Modified: opal/trunk/include/opal/mediafmt.h =================================================================== --- opal/trunk/include/opal/mediafmt.h 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/include/opal/mediafmt.h 2016-03-18 18:05:26 UTC (rev 34693) @@ -1480,7 +1480,7 @@ static const PString & TemporalSpatialTradeOffOption(); static const PString & TxKeyFramePeriodOption(); static const PString & RateControlPeriodOption(); // Period over which the rate controller maintains the target bit rate. - static const PString & RateControllerOption(); // String for controller algorithm. Empty is none. + static const PString & FrameDropOption(); // Boolean to allow frame dropping to maintain target bit rate, default true static const PString & FreezeUntilIntraFrameOption(); /**The "role" of the content in the video stream based on this media Modified: opal/trunk/include/opal/mediasession.h =================================================================== --- opal/trunk/include/opal/mediasession.h 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/include/opal/mediasession.h 2016-03-18 18:05:26 UTC (rev 34693) @@ -109,6 +109,7 @@ unsigned m_totalFrames; unsigned m_keyFrames; + unsigned m_droppedFrames; PTime m_lastKeyFrameTime; unsigned m_fullUpdateRequests; unsigned m_pictureLossRequests; Modified: opal/trunk/include/opal/patch.h =================================================================== --- opal/trunk/include/opal/patch.h 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/include/opal/patch.h 2016-03-18 18:05:26 UTC (rev 34693) @@ -41,7 +41,6 @@ #include <opal/mediastrm.h> #include <opal/mediasession.h> #include <opal/mediacmd.h> -#include <codec/ratectl.h> #include <list> @@ -273,19 +272,13 @@ RTP_DataFrameList m_intermediateFrames; RTP_DataFrameList m_finalFrames; -#if OPAL_VIDEO - void SetRateControlParameters(const OpalMediaFormat & mediaFormat); - bool RateControlExceeded(bool & forceIFrame); - OpalVideoRateController * m_rateController; - -#if OPAL_STATISTICS +#if OPAL_VIDEO && OPAL_STATISTICS OpalVideoFormat m_videoFormat; OpalVideoFormat::FrameDetectorPtr m_keyFrameDetector; typedef map<RTP_SyncSourceId, OpalVideoStatistics> VideoStatsMap; VideoStatsMap m_videoStatistics; PDECLARE_MUTEX(m_videoStatsMutex); #endif -#endif }; PList<Sink> m_sinks; Modified: opal/trunk/plugins/video/VP8-WebM/vp8_webm_2013.vcxproj =================================================================== --- opal/trunk/plugins/video/VP8-WebM/vp8_webm_2013.vcxproj 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/plugins/video/VP8-WebM/vp8_webm_2013.vcxproj 2016-03-18 18:05:26 UTC (rev 34693) @@ -244,6 +244,11 @@ <ItemGroup> <ClCompile Include="vp8_webm.cxx" /> </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\..\samples\codectest\codectest_2013.vcxproj"> + <Project>{7bcc8831-22e0-4d87-8e8b-f6da0aefbed0}</Project> + </ProjectReference> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> Modified: opal/trunk/samples/codectest/main.cxx =================================================================== --- opal/trunk/samples/codectest/main.cxx 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/samples/codectest/main.cxx 2016-03-18 18:05:26 UTC (rev 34693) @@ -31,8 +31,7 @@ #include "precompile.h" #include "main.h" -#include <codec/ratectl.h> -#include <opal/patch.h> +//#include <opal/patch.h> #include <ptclib/random.h> @@ -90,7 +89,6 @@ "p-payload-size: Set size of maximum RTP payload for encoded data\n" "S-simultaneous: Number of simultaneous encode/decode threads\n" "T-statistics. output statistics files\n" - "C-rate-control. enable rate control\n" "d-drop: randomly drop N% of encoded packets\n" "-count: set number of frames to transcode\n" "-noprompt. do not prompt for commands, i.e. exit when input closes\n" @@ -622,15 +620,14 @@ if (args.HasOption("frame-rate")) { - m_frameRate = args.GetOptionString("frame-rate").AsUnsigned(); - if (!m_grabber->SetFrameRate(m_frameRate)) { - cerr << "Video grabber device could not be set to frame rate " << m_frameRate << endl; + unsigned frameRate = args.GetOptionString("frame-rate").AsUnsigned(); + if (!m_grabber->SetFrameRate(frameRate)) { + cerr << "Video grabber device could not be set to frame rate " << frameRate << endl; return false; } } - m_frameRate = m_grabber->GetFrameRate(); - m_frameTime = mediaFormat.GetClockRate()/m_frameRate; + m_frameTime = mediaFormat.GetClockRate()/m_grabber->GetFrameRate(); mediaFormat.SetOptionInteger(OpalVideoFormat::FrameTimeOption(), m_frameTime); cout << "Grabber frame rate set to " << m_grabber->GetFrameRate() << endl; @@ -718,18 +715,6 @@ } cout << "Target bit rate set to " << mediaFormat.GetOptionInteger(OpalVideoFormat::TargetBitRateOption()) << " bps" << endl; - unsigned bitRate = mediaFormat.GetOptionInteger(OpalVideoFormat::TargetBitRateOption()); - PString rc = args.GetOptionString('C'); - if (rc.IsEmpty()) - m_rateController = NULL; - else { - m_rateController = PFactory<OpalVideoRateController>::CreateInstance(rc); - if (m_rateController != NULL) { - m_rateController->Open(mediaFormat); - cout << "Video rate controller enabled for bit rate " << bitRate << " bps and frame rate " << m_frameRate << endl; - } - } - if (args.HasOption('T')) m_frameFilename = "frame_stats.csv"; @@ -919,7 +904,6 @@ PUInt64 totalEncodedPacketCount = 0; PUInt64 totalOutputFrameCount = 0; PUInt64 totalEncodedByteCount = 0; - PUInt64 skippedFrames = 0; PUInt64 totalDroppedPacketCount = 0; PINDEX largestPacket = 0; @@ -934,10 +918,6 @@ PTimeInterval startTick = PTimer::Tick(); - if (isVideo) { - ((VideoThread *)this)->m_bitRateCalc.SetQuanta(m_frameTime/90); - } - ////////////////////////////////////////////// // // main loop @@ -967,7 +947,6 @@ } srcFrame.SetTimestamp(m_timestamp); - m_timestamp += m_frameTime; ++totalInputFrameCount; bool detectorSaysIntra = false; @@ -976,259 +955,193 @@ ////////////////////////////////////////////// // - // allow the rate controller to skip frames + // push frames through encoder // - bool rateControlForceIFrame = false; - if (m_rateController != NULL && m_rateController->SkipFrame(rateControlForceIFrame)) { - coutMutex.Wait(); - cout << "Packet pacer forced skip of input frame " << totalInputFrameCount-1 << endl; - coutMutex.Signal(); - ++skippedFrames; - } - + RTP_DataFrameList encFrames; + if (m_encoder == NULL) + encFrames.Append(new RTP_DataFrame(srcFrame)); else { - - ////////////////////////////////////////////// - // - // push frames through encoder - // - RTP_DataFrameList encFrames; - if (m_encoder == NULL) - encFrames.Append(new RTP_DataFrame(srcFrame)); - else { - if (isVideo) { - if (m_forceIFrame) { - coutMutex.Wait(); - cout << "Decoder forced I-Frame at input frame " << totalInputFrameCount-1 << endl; - coutMutex.Signal(); - } - if (rateControlForceIFrame) { - coutMutex.Wait(); - cout << "Rate controller forced I-Frame at input frame " << totalInputFrameCount-1 << endl; - coutMutex.Signal(); - } - if (m_forceIFrame || rateControlForceIFrame) - m_encoder->ExecuteCommand(OpalVideoUpdatePicture()); + if (isVideo) { + if (m_forceIFrame) { + coutMutex.Wait(); + cout << "Decoder forced I-Frame at input frame " << totalInputFrameCount-1 << endl; + coutMutex.Signal(); } + if (m_forceIFrame) + m_encoder->ExecuteCommand(OpalVideoUpdatePicture()); + } - if (m_extensionHeader != 255) - srcFrame.SetHeaderExtension(1, 1, &m_extensionHeader, RTP_DataFrame::RFC5285_OneByte); + if (m_extensionHeader != 255) + srcFrame.SetHeaderExtension(1, 1, &m_extensionHeader, RTP_DataFrame::RFC5285_OneByte); - bool state = m_encoder->ConvertFrames(srcFrame, encFrames); - if (oldEncState != state) { - oldEncState = state; - cerr << "Encoder " << (state ? "restor" : "fail") << "ed at input frame " << totalInputFrameCount-1 << endl; - continue; - } - if (isVideo) - encoderSaysIntra = ((OpalVideoTranscoder *)m_encoder)->WasLastFrameIFrame(); + bool state = m_encoder->ConvertFrames(srcFrame, encFrames); + if (oldEncState != state) { + oldEncState = state; + cerr << "Encoder " << (state ? "restor" : "fail") << "ed at input frame " << totalInputFrameCount-1 << endl; + continue; } + if (isVideo) + encoderSaysIntra = ((OpalVideoTranscoder *)m_encoder)->WasLastFrameIFrame(); + } - ////////////////////////////////////////////// - // - // re-format encoded frames - // - unsigned long encodedPayloadSize = 0; - unsigned long encodedPacketCount = 0; - unsigned long encodedDataSize = 0; - for (PINDEX i = 0; i < encFrames.GetSize(); i++) { - encFrames[i].SetSequenceNumber(++sequenceNumber); - ++encodedPacketCount; - encodedPayloadSize += encFrames[i].GetPayloadSize(); - encodedDataSize += encFrames[i].GetPayloadSize() + encFrames[i].GetHeaderSize(); - switch (m_markerHandling) { - case SuppressMarkers : - encFrames[i].SetMarker(false); - break; - case ForceMarkers : - encFrames[i].SetMarker(true); - break; - default : - break; - } + ////////////////////////////////////////////// + // + // re-format encoded frames + // + unsigned long encodedPayloadSize = 0; + unsigned long encodedPacketCount = 0; + unsigned long encodedDataSize = 0; + for (PINDEX i = 0; i < encFrames.GetSize(); i++) { + encFrames[i].SetSequenceNumber(++sequenceNumber); + ++encodedPacketCount; + encodedPayloadSize += encFrames[i].GetPayloadSize(); + encodedDataSize += encFrames[i].GetPayloadSize() + encFrames[i].GetHeaderSize(); + switch (m_markerHandling) { + case SuppressMarkers : + encFrames[i].SetMarker(false); + break; + case ForceMarkers : + encFrames[i].SetMarker(true); + break; + default : + break; + } - m_pcapFile.WriteRTP(encFrames[i]); + m_pcapFile.WriteRTP(encFrames[i]); - if (g_infoCount > 0) { - RTP_DataFrame & rtp = encFrames[i]; - coutMutex.Wait(); - if (g_infoCount > 1) - cout << "Inframe=" << totalInputFrameCount << ",outframe=#" << i << ":pt=" << rtp.GetPayloadType() << ",psz=" << rtp.GetPayloadSize() << ",m=" << (rtp.GetMarker() ? "1" : "0") << ","; - cout << "ssrc=" << hex << rtp.GetSyncSource() << dec << ",ts=" << rtp.GetTimestamp() << ",seq = " << rtp.GetSequenceNumber(); - if (g_infoCount > 2) { - cout << "\n data="; - cout << hex << setfill('0') << ::setw(2); - for (PINDEX i = 0; i < std::min((PINDEX)10, rtp.GetPayloadSize()); ++i) - cout << (int)rtp.GetPayloadPtr()[i] << ' '; - cout << dec << setfill(' ') << ::setw(0); - } - cout << endl; - coutMutex.Signal(); + if (g_infoCount > 0) { + RTP_DataFrame & rtp = encFrames[i]; + coutMutex.Wait(); + if (g_infoCount > 1) + cout << "Inframe=" << totalInputFrameCount << ",outframe=#" << i << ":pt=" << rtp.GetPayloadType() << ",psz=" << rtp.GetPayloadSize() << ",m=" << (rtp.GetMarker() ? "1" : "0") << ","; + cout << "ssrc=" << hex << rtp.GetSyncSource() << dec << ",ts=" << rtp.GetTimestamp() << ",seq = " << rtp.GetSequenceNumber(); + if (g_infoCount > 2) { + cout << "\n data="; + cout << hex << setfill('0') << ::setw(2); + for (PINDEX i = 0; i < std::min((PINDEX)10, rtp.GetPayloadSize()); ++i) + cout << (int)rtp.GetPayloadPtr()[i] << ' '; + cout << dec << setfill(' ') << ::setw(0); } + cout << endl; + coutMutex.Signal(); } + } - totalEncodedPacketCount += encFrames.GetSize(); + totalEncodedPacketCount += encFrames.GetSize(); - if (isVideo && m_calcSNR) - ((VideoThread *)this)->SaveSNRFrame(srcFrame); + if (isVideo && m_calcSNR) + ((VideoThread *)this)->SaveSNRFrame(srcFrame); - ////////////////////////////////////////////// - // - // drop encoded frames if required - // - if (m_dropPercent > 0) { - RTP_DataFrameList::iterator it = encFrames.begin(); - while (it != encFrames.end()) { - if (PRandom::Number(100) >= m_dropPercent) + ////////////////////////////////////////////// + // + // drop encoded frames if required + // + if (m_dropPercent > 0) { + RTP_DataFrameList::iterator it = encFrames.begin(); + while (it != encFrames.end()) { + if (PRandom::Number(100) >= m_dropPercent) + ++it; + else { + ++totalDroppedPacketCount; + if (isVideo) + encFrames.erase(it++); + else { + it->SetPayloadSize(0); + it->SetDiscontinuity(1); ++it; - else { - ++totalDroppedPacketCount; - if (isVideo) - encFrames.erase(it++); - else { - it->SetPayloadSize(0); - it->SetDiscontinuity(1); - ++it; - } } } } + } - ////////////////////////////////////////////// - // - // push audio/video frames through NULL decoder - // - if (m_decoder == NULL) { - totalEncodedByteCount += encodedPayloadSize; - for (PINDEX i = 0; i < encFrames.GetSize(); i++) { - bool state = Write(encFrames[i]); + ////////////////////////////////////////////// + // + // push audio/video frames through NULL decoder + // + if (m_decoder == NULL) { + totalEncodedByteCount += encodedPayloadSize; + for (PINDEX i = 0; i < encFrames.GetSize(); i++) { + bool state = Write(encFrames[i]); + if (oldOutState != state) { + oldOutState = state; + cerr << "Output write " << (state ? "restor" : "fail") << "ed at input frame " << totalInputFrameCount << endl; + } + totalOutputFrameCount++; + } + } + + ////////////////////////////////////////////// + // + // push audio/video frames through explicit decoder + // + else { + totalEncodedByteCount += encodedPayloadSize; + RTP_DataFrameList outFrames; + for (PINDEX i = 0; i < encFrames.GetSize(); i++) { + if (encFrames[i].GetPayloadSize() > largestPacket) + largestPacket = encFrames[i].GetPayloadSize(); + bool state = m_decoder->ConvertFrames(encFrames[i], outFrames); + if (oldDecState != state) { + oldDecState = state; + cerr << "Decoder " << (state ? "restor" : "fail") << "ed at input frame " << totalInputFrameCount-1 << endl; + continue; + } + if (outFrames.GetSize() > 1) + cerr << "Non rate controlled video decoder returned != 1 output frame for input frame " << totalInputFrameCount-1 << endl; + else if (outFrames.GetSize() == 1) { + if (isVideo) { + decoderSaysIntra = ((OpalVideoTranscoder *)m_decoder)->WasLastFrameIFrame(); + if (g_infoCount > 1) { + coutMutex.Wait(); + cout << "Decoder generated payload of size " << outFrames[0].GetPayloadSize() << endl; + coutMutex.Signal(); + } + } + bool state = Write(outFrames[0]); if (oldOutState != state) { oldOutState = state; cerr << "Output write " << (state ? "restor" : "fail") << "ed at input frame " << totalInputFrameCount << endl; } + if (isVideo && m_calcSNR) + ((VideoThread *)this)->CalcSNR(outFrames[0]); totalOutputFrameCount++; } } - ////////////////////////////////////////////// - // - // push audio/video frames through explicit decoder - // - else if (m_rateController == NULL) { - totalEncodedByteCount += encodedPayloadSize; - if (isVideo) - ((VideoThread *)this)->CalcVideoPacketStats(encFrames, ((OpalVideoTranscoder *)m_decoder)->WasLastFrameIFrame()); - RTP_DataFrameList outFrames; + if (isVideo) { + bool detectedInter = false; for (PINDEX i = 0; i < encFrames.GetSize(); i++) { - if (encFrames[i].GetPayloadSize() > largestPacket) - largestPacket = encFrames[i].GetPayloadSize(); - bool state = m_decoder->ConvertFrames(encFrames[i], outFrames); - if (oldDecState != state) { - oldDecState = state; - cerr << "Decoder " << (state ? "restor" : "fail") << "ed at input frame " << totalInputFrameCount-1 << endl; - continue; + switch (videoFormat.GetFrameType(encFrames[i].GetPayloadPtr(), encFrames[i].GetPayloadSize(), videoDetector)) { + case OpalVideoFormat::e_IntraFrame : + detectorSaysIntra = true; + break; + case OpalVideoFormat::e_InterFrame : + detectedInter = true; + break; + default : + break; } - if (outFrames.GetSize() > 1) - cerr << "Non rate controlled video decoder returned != 1 output frame for input frame " << totalInputFrameCount-1 << endl; - else if (outFrames.GetSize() == 1) { - if (isVideo) { - decoderSaysIntra = ((OpalVideoTranscoder *)m_decoder)->WasLastFrameIFrame(); - if (g_infoCount > 1) { - coutMutex.Wait(); - cout << "Decoder generated payload of size " << outFrames[0].GetPayloadSize() << endl; - coutMutex.Signal(); - } - } - bool state = Write(outFrames[0]); - if (oldOutState != state) { - oldOutState = state; - cerr << "Output write " << (state ? "restor" : "fail") << "ed at input frame " << totalInputFrameCount << endl; - } - if (isVideo && m_calcSNR) - ((VideoThread *)this)->CalcSNR(outFrames[0]); - totalOutputFrameCount++; - } } - - if (isVideo) { - bool detectedInter = false; - for (PINDEX i = 0; i < encFrames.GetSize(); i++) { - switch (videoFormat.GetFrameType(encFrames[i].GetPayloadPtr(), encFrames[i].GetPayloadSize(), videoDetector)) { - case OpalVideoFormat::e_IntraFrame : - detectorSaysIntra = true; - break; - case OpalVideoFormat::e_InterFrame : - detectedInter = true; - break; - default : - break; - } - } - if (!videoDetectorFailed && !detectorSaysIntra && !detectedInter) { - videoDetectorFailed = true; + if (!videoDetectorFailed && !detectorSaysIntra && !detectedInter) { + videoDetectorFailed = true; + coutMutex.Wait(); + cout << "Video detector could not determine if I-Frame or P-Frame" << endl; + coutMutex.Signal(); + } + } + else { + for (PINDEX i = 0; i < encFrames.GetSize(); i++) { + OpalAudioFormat::FrameType type = audioFormat.GetFrameType(encFrames[i].GetPayloadPtr(), encFrames[i].GetPayloadSize(), audioDetector); + if (type & OpalAudioFormat::e_SilenceFrame) { coutMutex.Wait(); - cout << "Video detector could not determine if I-Frame or P-Frame" << endl; + cout << "Audio frame silent." << endl; coutMutex.Signal(); } } - else { - for (PINDEX i = 0; i < encFrames.GetSize(); i++) { - OpalAudioFormat::FrameType type = audioFormat.GetFrameType(encFrames[i].GetPayloadPtr(), encFrames[i].GetPayloadSize(), audioDetector); - if (type & OpalAudioFormat::e_SilenceFrame) { - coutMutex.Wait(); - cout << "Audio frame silent." << endl; - coutMutex.Signal(); - } - } - } } - - ////////////////////////////////////////////// - // - // push video frames into rate controller - // - else - m_rateController->Push(encFrames, ((OpalVideoTranscoder *)m_encoder)->WasLastFrameIFrame()); } - ////////////////////////////////////////////// - // - // pop video frames from rate controller and explicit decoder - // - if (m_rateController != NULL) { - for (;;) { - bool outIFrame; - RTP_DataFrameList pacedFrames; - if (!m_rateController->Pop(pacedFrames, outIFrame, false)) - break; - ((VideoThread *)this)->CalcVideoPacketStats(pacedFrames, outIFrame); - RTP_DataFrameList outFrames; - for (PINDEX i = 0; i < pacedFrames.GetSize(); i++) { - totalEncodedByteCount += pacedFrames[i].GetPayloadSize(); - bool state = m_decoder->ConvertFrames(pacedFrames[i], outFrames); - if (oldDecState != state) { - oldDecState = state; - cerr << "Decoder " << (state ? "restor" : "fail") << "ed at input frame " << totalInputFrameCount-1 << endl; - continue; - } - if (outFrames.GetSize() > 1) - cerr << "Rate controlled video decoder returned > 1 output frame for input frame " << totalInputFrameCount-1 << endl; - else if (outFrames.GetSize() == 1) { - decoderSaysIntra = ((OpalVideoTranscoder *)m_decoder)->WasLastFrameIFrame(); - bool state = Write(outFrames[0]); - if (oldOutState != state) { - oldOutState = state; - cerr << "Output write " << (state ? "restor" : "fail") << "ed at input frame " << totalInputFrameCount-1 << endl; - } - if (isVideo && m_calcSNR) - ((VideoThread *)this)->CalcSNR(outFrames[0]); - totalOutputFrameCount++; - } - } - } - } - if (detectorSaysIntra || encoderSaysIntra || decoderSaysIntra) { coutMutex.Wait(); cout << "I-Frame at input frame " << totalInputFrameCount - 1 << " from "; @@ -1312,10 +1225,6 @@ OUTPUT_BPS(cout, maximumBitRate); cout << '\n'; - if (m_rateController != NULL) - cout << "Rate controller skipped " << skippedFrames - << " frames (" << (skippedFrames * 100.0)/totalInputFrameCount << "%)\n"; - cout << "CPU used: " << cpuTimes << endl; coutMutex.Signal(); @@ -1327,6 +1236,7 @@ bool AudioThread::Read(RTP_DataFrame & frame) { + m_timestamp += m_frameTime; frame.SetPayloadSize(m_readSize); return m_recorder->Read(frame.GetPayloadPtr(), m_readSize); } @@ -1349,8 +1259,15 @@ bool VideoThread::Read(RTP_DataFrame & data) { - if (m_singleStep) + if (m_singleStep) { m_frameWait.Wait(); + m_timestamp += m_frameTime; + } + else { + PTimeInterval currentGrabTime = PTimer::Tick(); + m_timestamp += (int)((currentGrabTime - m_lastGrabTime).GetMilliSeconds()*OpalMediaFormat::VideoClockRate/1000); + m_lastGrabTime = currentGrabTime; + } data.SetPayloadSize(m_grabber->GetMaxFrameBytes()+sizeof(OpalVideoTranscoder::FrameHeader)); data.SetMarker(TRUE); @@ -1390,40 +1307,6 @@ } -void VideoThread::CalcVideoPacketStats(const RTP_DataFrameList & packets, bool isIFrame) -{ - static unsigned maximumBitRate = 0; - static unsigned maximumAvgBitRate = 0; - - for (PINDEX i = 0; i < packets.GetSize(); ++i) { - - //m_bitRateCalc.AddPacket(packets[i].GetPayloadSize()); - - if (m_rateController != NULL) { - OpalBitRateCalculator & m_bitRateCalc = m_rateController->m_bitRateCalc; - - unsigned r = m_bitRateCalc.GetBitRate(); - if (r > maximumBitRate) - maximumBitRate = r; - - unsigned a = m_bitRateCalc.GetAverageBitRate(); - if (a > maximumAvgBitRate) - maximumAvgBitRate = a; - - PStringStream str; - str << "index=" << (packets[i].GetTimestamp() / 3600) - << ",ps=" << packets[i].GetPayloadSize() - << ",rate=" << r - << ",avg=" << a - << ",maxrate=" << maximumBitRate - << ",maxavg=" << maximumAvgBitRate - << ",f=" << (isIFrame?"I":"") << (packets[i].GetMarker()?"M":""); - ((VideoThread *)this)->WriteFrameStats(str); - } - } -} - - void VideoThread::WriteFrameStats(const PString & str) { if (!m_frameFilename.IsEmpty()) { Modified: opal/trunk/samples/codectest/main.h =================================================================== --- opal/trunk/samples/codectest/main.h 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/samples/codectest/main.h 2016-03-18 18:05:26 UTC (rev 34693) @@ -44,7 +44,6 @@ , m_num(num) , m_timestamp(0) , m_markerHandling(NormalMarkers) - , m_rateController(NULL) , m_dropPercent(0) { } @@ -94,7 +93,6 @@ PDECLARE_NOTIFIER(OpalMediaCommand, TranscoderThread, OnTranscoderCommand); bool m_forceIFrame; - OpalVideoRateController * m_rateController; int m_framesToTranscode; int m_frameTime; bool m_calcSNR; @@ -160,7 +158,6 @@ virtual bool Write(const RTP_DataFrame & frame); virtual void Stop(); - void CalcVideoPacketStats(const RTP_DataFrameList & frames, bool isIFrame); void WriteFrameStats(const PString & str); PVideoInputDevice * m_grabber; @@ -168,7 +165,7 @@ bool m_singleStep; PSemaphore m_frameWait; - unsigned m_frameRate; + PTimeInterval m_lastGrabTime; void SaveSNRFrame(const RTP_DataFrame & src); void CalcSNR(const RTP_DataFrame & src); @@ -186,8 +183,6 @@ double m_sumCbSNR; double m_sumCrSNR; PInt64 m_snrCount; - - OpalBitRateCalculator m_bitRateCalc; }; Modified: opal/trunk/src/codec/opalpluginmgr.cxx =================================================================== --- opal/trunk/src/codec/opalpluginmgr.cxx 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/src/codec/opalpluginmgr.cxx 2016-03-18 18:05:26 UTC (rev 34693) @@ -932,6 +932,9 @@ if (src.GetPayloadSize() == 0) return true; + if (ShouldDropFrame(src.GetTimestamp())) + return true; + // get the size of the output buffer int outputDataSize = std::max(GetOptimalDataFrameSize(false), (PINDEX)getOutputDataSizeControl.Call((void *)NULL, (unsigned *)NULL, context)); @@ -1021,6 +1024,7 @@ if (m_lastFrameWasIFrame) m_encodingIntraFrameControl.IntraFrameDetected(); + UpdateFrameDrop(dstList); return true; } Deleted: opal/trunk/src/codec/ratectl.cxx =================================================================== --- opal/trunk/src/codec/ratectl.cxx 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/src/codec/ratectl.cxx 2016-03-18 18:05:26 UTC (rev 34693) @@ -1,455 +0,0 @@ -/* - * ratectl.h - * - * Video rate controller - * - * Open Phone Abstraction Library (OPAL) - * - * Copyright (C) 2007 Matthias Schneider - * Copyright (C) 2008 Post Increment - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.0 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. - * - * The Original Code is Open Phone Abstraction Library. - * - * The Initial Developer of the Original Code is Matthias Schneider - * - * Contributor(s): Post Increment - * - * $Revision$ - * $Author$ - * $Date$ - */ - -#include <ptlib.h> -#include <list> -using namespace std; - -#ifdef __GNUC__ -#pragma implementation "ratectl.h" -#endif - -#include <opal_config.h> -#include <codec/ratectl.h> - -#if OPAL_VIDEO - -#include <opal/mediafmt.h> - - -// -// 20 bytes for nominal TCP header -// 8 bytes for nominal UDP header -// -#define UDP_OVERHEAD (20 + 8) - -// -// size of history used for calculating average packet size -// -#define PACKET_HISTORY_SIZE 5 - -#define new PNEW - - -///////////////////////////////////////////////////////////////////////////// -// -// -// - -OpalBitRateCalculator::OpalBitRateCalculator() -{ - Reset(); -} - -PInt64 OpalBitRateCalculator::GetNow() -{ - return (PTime().GetTimestamp()+500)/1000; -} - -void OpalBitRateCalculator::Reset() -{ - m_first = true; - m_bitRate = 0; - - m_historySize = 0; - m_totalSize = 0; - m_historyFrames = 0; - - m_history.clear(); -} - -void OpalBitRateCalculator::SetQuanta(unsigned quanta_) -{ - m_quanta = quanta_; -} - -void OpalBitRateCalculator::AddPacket(PINDEX size, bool marker) -{ - PInt64 now = GetNow(); - if (m_first) { - m_baseTimeStamp = now; - m_first = false; - } - - m_history.push_back(History(size, now, marker)); - m_historySize += size; - m_totalSize += size; - - if (marker) - ++m_historyFrames; - - Flush(); -} - -unsigned OpalBitRateCalculator::GetTrialBitRate(PINDEX size) -{ - PInt64 now = GetNow(); - Flush(now); - - unsigned trialBitRate = 0; - - if (m_history.size() > 0) - trialBitRate = (unsigned)((size + (PInt64)m_historySize) * 8 * 1000 / (m_quanta + (now - m_history.front().m_timeStamp))); - - return trialBitRate; -} - -unsigned OpalBitRateCalculator::GetBitRate() -{ - PInt64 now = GetNow(); - Flush(now); - - if (m_history.size() > 0) - m_bitRate = (unsigned)(((PInt64)m_historySize * 8 * 1000) / (m_quanta + (now - m_history.front().m_timeStamp))); - - return m_bitRate; -} - -unsigned OpalBitRateCalculator::GetAverageBitRate() -{ - if (m_first) - return 0; - - return (unsigned)(((m_totalSize * 8 * 1000) / (m_quanta + GetNow() - m_baseTimeStamp))); -} - -PInt64 OpalBitRateCalculator::GetTotalSize() const -{ - return m_totalSize; -} - -void OpalBitRateCalculator::Flush() -{ - Flush(GetNow()); -} - -void OpalBitRateCalculator::Flush(PInt64 now) -{ - // flush history - while ((m_history.size() > 0) && ((now - m_history.front().m_timeStamp) > 1000)) { - m_historySize -= m_history.front().m_size; - if (m_history.front().m_marker) - --m_historyFrames; - m_history.pop_front(); - } -} - -PInt64 OpalBitRateCalculator::GetTotalTime() const -{ - return GetNow() - m_baseTimeStamp; -} - -unsigned OpalBitRateCalculator::GetHistoryFrames() const -{ - if (m_history.size() == 0) - return 0; - - return m_historyFrames + (m_history.back().m_marker ? 0 : 1); -} - -// -// This file implements a video rate controller that seeks to maintain a constant bit rate -// by indicating when encoded video frames should be dropped -// -// The instantaneous bit rate is monitored by calculating the total number of bytes that have been -// transmitted over the past few seconds. This decision to drop a frame is based on whether the -// the actual transmitted count is less, or more, then the number of bytes that would have been -// transmitted if the target bit rate had been maintained. -// -// The size of this history used to calculate the current bit rate is set when the rate -// controller is opened. Experience shows that a history of 5000ms seems to work well. -// -// The decision to drop a frame is made before the frame is encoded. The rate controller predicts -// the probable size of the encoded frame by looking at the previous 5 encoded frames. Experiments -// were done with longer histories (for example the same history used for the bit rate calculation) -// but it was found that this tended to over-estimate the probable frame size due to the inclusion -// of occasional I-frames. -// -// The maximum number of consecutive dropped frames is also set when the rate controller is opened. -// -// The bit rate calculations take into account the 28 bytes of IP and UDP overhead on every RTP packet -// This can make a big difference when small video packets are being transmitted -// -// Additionally, this code can also enforce an output frame rate -// - -///////////////////////////////////////////////////////////////////////////// - -static int udiff(unsigned int const subtrahend, unsigned int const subtractor) -{ - return subtrahend - subtractor; -} - - -static double square(double const arg) -{ - return(arg*arg); -} - - -double OpalCalcSNR(const BYTE * src1, const BYTE * src2, PINDEX dataLen) -{ - double diff2 = 0.0; - for (PINDEX i = 0; i < dataLen; ++i) - diff2 += square(udiff(*src1++, *src2++)); - - double const snr = diff2 / dataLen / 255; - - return snr; -} - - -///////////////////////////////////////////////////////////////////////////// - -OpalVideoRateController::OpalVideoRateController() -{ - m_targetBitRate = 0; - m_outputFrameTime = 0; -} - -OpalVideoRateController::~OpalVideoRateController() -{ -} - -void OpalVideoRateController::Open(const OpalMediaFormat & mediaFormat) -{ - m_targetBitRate = mediaFormat.GetOptionInteger(OpalVideoFormat::TargetBitRateOption()); - m_outputFrameTime = mediaFormat.GetOptionInteger(OpalVideoFormat::FrameTimeOption()) / 90; - m_inputFrameCount = 0; - m_outputFrameCount = 0; - - PTRACE(4, "RateController\tOpened with rate " << m_targetBitRate << " and frame rate " << 1000 / m_outputFrameTime); - - m_bitRateCalc.SetQuanta(m_outputFrameTime); -} - - -void OpalVideoRateController::Push(RTP_DataFrameList & inputFrames, bool iFrame) -{ - if (inputFrames.GetSize() == 0) - return; - - inputFrames.DisallowDeleteObjects(); - - // add the new data to the unsent frame list - DWORD startTimeStamp = inputFrames[0].GetTimestamp(); - for (PINDEX i = 0; i < inputFrames.GetSize(); ++i) { - PAssert(inputFrames[0].GetTimestamp() == startTimeStamp, "Packet pacer input cannot span frames"); - m_packets.push_back(PacketEntry(&inputFrames[i], iFrame)); - } - - inputFrames.RemoveAll(); - inputFrames.AllowDeleteObjects(); - - ++m_inputFrameCount; -} - -bool OpalVideoRateController::Pop(RTP_DataFrameList & outputPackets, bool & iFrame, bool /*force*/) -{ - while (m_packets.size() > 0) { - outputPackets.Append(m_packets[0].m_rtp); - iFrame = m_packets[0].m_iFrame; - m_bitRateCalc.AddPacket(m_packets[0].m_rtp->GetPayloadSize(), m_packets[0].m_rtp->GetMarker()); - m_packets.pop_front(); - } - return outputPackets.GetSize() != 0; -} - -///////////////////////////////////////////////////////////////////////////// - -// -// This file implements a video rate controller that seeks to maintain a constant bit rate -// by indicating when encoded video frames should be dropped -// -// To use the rate controller, open it with the appropriate parameters. -// -// Before encoding a potential output frame, use the SkipFrame function to determine if the -// frame should be skipped. If the frame is not skipped, encode the frame and then call AddFrame -// with the parameters of the final data. -// - -class OpalStandardVideoRateController : public OpalVideoRateController -{ - public: - OpalStandardVideoRateController(); - - /** Open the rate controller with the specific parameters - */ - void Open( - const OpalMediaFormat & mediaFormat // media format for video - ); - - /** Determine if the next frame should be skipped. - * The rate controller can also indicate whether the next frame should - * be encoded as an I-frame, which is useful if many frames have been skipped - */ - virtual bool SkipFrame( - bool & forceIFrame - ); - - bool Pop(RTP_DataFrameList & outputPackets, bool & iFrame, bool force); - - protected: - bool CheckFrameRate(bool reporting); - bool CheckBitRate(bool reporting, unsigned currentBitRate); - PInt64 startTime; - PInt64 now; - PInt64 lastReport; -}; - - -PFACTORY_CREATE(PFactory<OpalVideoRateController>, OpalStandardVideoRateController, "Standard", false); - - -OpalStandardVideoRateController::OpalStandardVideoRateController() -{ -} - -void OpalStandardVideoRateController::Open(const OpalMediaFormat & fmt) -{ - OpalVideoRateController::Open(fmt); - - int scaler = fmt.GetOptionInteger("Bit Rate Scaler", 100); - m_targetBitRate = m_targetBitRate * scaler / 100; - - PTRACE(4, "StandardRateController\tOpened with rate " << m_targetBitRate << " and frame rate " << 1000 / m_outputFrameTime); - - startTime = PTimer::Tick().GetMilliSeconds(); - lastReport = 0; -} - -bool OpalStandardVideoRateController::SkipFrame(bool & iFrame) -{ - // increment incoming frame count - ++m_inputFrameCount; - - // never force I-frames - iFrame = false; - - // get "now" - now = PTimer::Tick().GetMilliSeconds(); - - // set flag for reporting every second - bool reporting = (now - lastReport) > 1000; - if (reporting) - lastReport = now; - - // get bit rate now to avoid flushing history multiple times - unsigned currentBitRate = m_bitRateCalc.GetBitRate(); - - // check frame rate - if (CheckFrameRate(reporting)) - return true; - - // checl bit rate - return CheckBitRate(reporting, currentBitRate); -} - -bool OpalStandardVideoRateController::CheckFrameRate(bool PTRACE_PARAM(reporting)) -{ - m_bitRateCalc.Flush(); - - unsigned frameHistoryCount = m_bitRateCalc.GetHistoryCount(); - - // the first one is always free - if (frameHistoryCount == 0) { - PTRACE(5, "RateController\tHistory too small for frame rate control"); - return false; - } - - PTRACE_IF(3, reporting, "RateController\tReport:Total frames:in=" << m_inputFrameCount - << ",out=" << m_outputFrameCount - << ",dropped=" << (m_inputFrameCount - m_outputFrameCount) - << "(" << (m_inputFrameCount < 1 ? 0 : ((m_inputFrameCount - m_outputFrameCount) * 100 / m_inputFrameCount)) << "%)"); - - unsigned outputFrameTime = m_bitRateCalc.GetQuanta(); - - // if maintaining a frame rate, check to see if frame should be dropped - // to make this decision, check what the rate would be if this frame was not dropped - if (outputFrameTime > 0) { - - // if the frame history covers zero time, it is doubtful that outputting this - // frame will result in an invalid frame rate - PInt64 frameRateHistoryDuration = now - m_bitRateCalc.GetEarliestHistoryTime(); - if (frameRateHistoryDuration == 0) - return false; - - // output report now we have useful statistics - PTRACE_IF(3, reporting, "RateController\tReport:" - "in=" << ((m_inputFrameCount-0) * 1000) / (now - startTime) << " fps," - "out=" << ((m_outputFrameCount-0) * 1000) / (now - startTime) << " fps," - "target=" << (1000 / m_outputFrameTime) << " fps"); - - if ((frameRateHistoryDuration + outputFrameTime) > (m_bitRateCalc.GetHistoryFrames()+1) * outputFrameTime) { - PTRACE(3, "RateController\tSkipping frame to enforce frame rate"); - return true; - } - } - - return false; -} - -bool OpalStandardVideoRateController::CheckBitRate(bool PTRACE_PARAM(reporting), unsigned PTRACE_PARAM(currentBitRate)) -{ - if (m_bitRateCalc.GetHistoryCount() == 0) - return false; - - // calculate average payload size - unsigned averagePayloadSize = (int)(m_bitRateCalc.GetHistorySize() / m_bitRateCalc.GetHistoryCount()); - - // show some statistics - PTRACE_IF(3, reporting, "RateController\tReport:" - "current=" << currentBitRate << " bps," - "target=" << m_targetBitRate << " bps"); - - // allow the packet if the expected history size with this packet is less - // than the target history size - unsigned trialBitRate = m_bitRateCalc.GetTrialBitRate(averagePayloadSize); - if (trialBitRate <= m_targetBitRate) - return false; - - PTRACE(3, "RateController\tSkipping frame to enforce bit rate"); - return true; -} - - -bool OpalStandardVideoRateController::Pop(RTP_DataFrameList & outputPackets, bool & iFrame, bool force) -{ - if (!OpalVideoRateController::Pop(outputPackets, iFrame, force)) - return false; - - ++m_outputFrameCount; - return true; -} - - - -#endif // OPAL_VIDEO Modified: opal/trunk/src/codec/vidcodec.cxx =================================================================== --- opal/trunk/src/codec/vidcodec.cxx 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/src/codec/vidcodec.cxx 2016-03-18 18:05:26 UTC (rev 34693) @@ -128,6 +128,10 @@ , m_freezeTillIFrame(false) , m_frozenTillIFrame(false) , m_lastFrameWasIFrame(false) + , m_frameDropPeriod(0) + , m_frameDropRate(0) + , m_frameDropBits(0) + , m_lastTimestamp(UINT_MAX) { acceptEmptyPayload = true; } @@ -153,6 +157,11 @@ SetFrameBytes(inputMediaFormat, OpalVideoFormat::MaxRxFrameWidthOption(), OpalVideoFormat::MaxRxFrameHeightOption(), m_inDataSize); SetFrameBytes(outputMediaFormat, OpalVideoFormat::FrameWidthOption(), OpalVideoFormat::FrameHeightOption(), m_outDataSize); + int periodMilliseconds = outputMediaFormat.GetOptionInteger(OpalVideoFormat::RateControlPeriodOption()); + m_frameDropPeriod = periodMilliseconds*outputMediaFormat.GetTimeUnits(); + m_frameDropRate = periodMilliseconds > 0 && outputMediaFormat.GetOptionBoolean(OpalVideoFormat::FrameDropOption(), true) + ? (unsigned)(outputMediaFormat.GetOptionInteger(OpalMediaFormat::TargetBitRateOption())*1000LL/periodMilliseconds) : 0; + m_freezeTillIFrame = inputMediaFormat.GetOptionBoolean(OpalVideoFormat::FreezeUntilIntraFrameOption()) || outputMediaFormat.GetOptionBoolean(OpalVideoFormat::FreezeUntilIntraFrameOption()); @@ -199,6 +208,58 @@ } +#if OPAL_STATISTICS +void OpalVideoTranscoder::GetStatistics(OpalMediaStatistics & statistics) const +{ + OpalTranscoder::GetStatistics(statistics); + statistics.m_droppedFrames = m_framesDropped; +} +#endif + + +bool OpalVideoTranscoder::ShouldDropFrame(RTP_Timestamp ts) +{ + if (m_frameDropRate == 0 || m_frameDropPeriod == 0) + return false; + + if (m_lastTimestamp == UINT_MAX) { + m_lastTimestamp = ts; + return false; + } + + RTP_Timestamp delta = ts - m_lastTimestamp; + m_lastTimestamp = ts; + +PTRACE(4, "ts=" << ts << ' ' << delta); + if (delta == 0) + delta = outputMediaFormat.GetFrameTime(); + + /* Add in extra bits we can send for this frame, but don't keep adding + beyond a headroom level or prolonged under utilisation of bits builds + up a huge amount we can then over utilise. */ + unsigned bitsForOneFrame = (unsigned)((uint64_t)m_frameDropRate*delta/m_frameDropPeriod); + if (m_frameDropBits > bitsForOneFrame) + m_frameDropBits -= bitsForOneFrame; + else + m_frameDropBits = 0; + + if (m_frameDropBits < m_frameDropRate) + return false; + + // Sent too many bits, drop frame + PTRACE(4, "Frame dropped, overrun=" << PString(PString::ScaleSI, m_frameDropBits, 3) << "bits."); + ++m_framesDropped; + return true; +} + + +void OpalVideoTranscoder::UpdateFrameDrop(const RTP_DataFrameList & encoded) +{ + for (RTP_DataFrameList::const_iterator it = encoded.begin(); it != encoded.end(); ++it) + m_frameDropBits += it->GetPayloadSize()*8; +} + + void OpalVideoTranscoder::SendIFrameRequest(unsigned sequenceNumber, unsigned timestamp) { m_frozenTillIFrame = m_freezeTillIFrame; Modified: opal/trunk/src/opal/mediafmt.cxx =================================================================== --- opal/trunk/src/opal/mediafmt.cxx 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/src/opal/mediafmt.cxx 2016-03-18 18:05:26 UTC (rev 34693) @@ -1885,8 +1885,8 @@ const PString & OpalVideoFormat::TemporalSpatialTradeOffOption() { static const PConstString s(PLUGINCODEC_OPTION_TEMPORAL_SPATIAL_TRADE_OFF);return s; } const PString & OpalVideoFormat::TxKeyFramePeriodOption() { static const PConstString s(PLUGINCODEC_OPTION_TX_KEY_FRAME_PERIOD); return s; } const PString & OpalVideoFormat::RateControlPeriodOption() { static const PConstString s(PLUGINCODEC_OPTION_RATE_CONTROL_PERIOD); return s; } -const PString & OpalVideoFormat::RateControllerOption() { static const PConstString s("Rate Controller"); return s; } -const PString & OpalVideoFormat::FreezeUntilIntraFrameOption() { static const PConstString s("Freeze Until Intra-Frame"); return s; } +const PString & OpalVideoFormat::FrameDropOption() { static const PConstString s("Frame Drop"); return s; } +const PString & OpalVideoFormat::FreezeUntilIntraFrameOption() { static const PConstString s("Freeze Until Intra-Frame"); return s; } const PString & OpalVideoFormat::ContentRoleOption() { static const PConstString s("Content Role"); return s; } const PString & OpalVideoFormat::ContentRoleMaskOption() { static const PConstString s("Content Role Mask"); return s; } #if OPAL_SDP @@ -1956,13 +1956,13 @@ AddOption(new OpalMediaOptionUnsigned(OpalVideoFormat::MaxRxFrameWidthOption(), false, OpalMediaOption::MinMerge, maxFrameWidth, 16, 32767)); AddOption(new OpalMediaOptionUnsigned(OpalVideoFormat::MaxRxFrameHeightOption(), false, OpalMediaOption::MinMerge, maxFrameHeight, 16, 32767)); if (rtpPayloadType < RTP_DataFrame::LastKnownPayloadType || encodingName != NULL) { - AddOption(new OpalMediaOptionUnsigned(OpalVideoFormat::TxKeyFramePeriodOption(), false, OpalMediaOption::AlwaysMerge, 125, 0, 1000)); - AddOption(new OpalMediaOptionUnsigned(OpalVideoFormat::RateControlPeriodOption(), false, OpalMediaOption::AlwaysMerge, 1000, 100, 60000)); - AddOption(new OpalMediaOptionUnsigned(OpalMediaFormat::MaxTxPacketSizeOption(), true, OpalMediaOption::MinMerge, PluginCodec_RTP_MaxPayloadSize, 100 )); - AddOption(new OpalMediaOptionString (OpalVideoFormat::RateControllerOption(), false )); - AddOption(new OpalMediaOptionBoolean (OpalVideoFormat::FreezeUntilIntraFrameOption(), false, OpalMediaOption::NoMerge, false )); + AddOption(new OpalMediaOptionUnsigned(OpalVideoFormat::TxKeyFramePeriodOption(), false, OpalMediaOption::AlwaysMerge, 125, 0, 1000)); + AddOption(new OpalMediaOptionUnsigned(OpalVideoFormat::RateControlPeriodOption(), false, OpalMediaOption::AlwaysMerge, 1000, 100, 60000)); + AddOption(new OpalMediaOptionUnsigned(OpalMediaFormat::MaxTxPacketSizeOption(), true, OpalMediaOption::MinMerge, PluginCodec_RTP_MaxPayloadSize, 100 )); + AddOption(new OpalMediaOptionBoolean (OpalVideoFormat::FrameDropOption(), false, OpalMediaOption::NoMerge, true )); + AddOption(new OpalMediaOptionBoolean (OpalVideoFormat::FreezeUntilIntraFrameOption(), false, OpalMediaOption::NoMerge, false )); #if OPAL_SDP - AddOption(new OpalMediaOptionEnum (OpalVideoFormat::UseImageAttributeInSDP(), false, + AddOption(new OpalMediaOptionEnum (OpalVideoFormat::UseImageAttributeInSDP(), false, OpalVideoFormat::PEnumNames_ImageAttributeInSDP::Names(), OpalVideoFormat::NumImageAttributeInSDP, OpalMediaOption::AlwaysMerge, OpalVideoFormat::ImageAddrOffered)); #endif Modified: opal/trunk/src/opal/mediasession.cxx =================================================================== --- opal/trunk/src/opal/mediasession.cxx 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/src/opal/mediasession.cxx 2016-03-18 18:05:26 UTC (rev 34693) @@ -101,6 +101,7 @@ OpalVideoStatistics::OpalVideoStatistics() : m_totalFrames(0) , m_keyFrames(0) + , m_droppedFrames(0) , m_lastKeyFrameTime(0) , m_fullUpdateRequests(0) , m_pictureLossRequests(0) @@ -388,7 +389,8 @@ strm << setw(indent) << "Total video frames" << " = " << m_totalFrames << '\n' << setw(indent) << "Average Frame rate" << " = " << GetAverageFrameRate("fps", 1) << '\n' << setw(indent) << "Current Frame rate" << " = " << GetCurrentFrameRate("fps", 1) << '\n' - << setw(indent) << "Total key frames" << " = " << m_keyFrames << '\n'; + << setw(indent) << "Total key frames" << " = " << m_keyFrames << '\n' + << setw(indent) << "Dropped frames" << " = " << m_droppedFrames << '\n'; if (m_videoQuality >= 0) strm << setw(indent) << "Video quality (QP)" << " = " << m_videoQuality << '\n'; } Modified: opal/trunk/src/opal/patch.cxx =================================================================== --- opal/trunk/src/opal/patch.cxx 2016-03-18 18:04:37 UTC (rev 34692) +++ opal/trunk/src/opal/patch.cxx 2016-03-18 18:05:26 UTC (rev 34693) @@ -521,16 +521,9 @@ , m_stream(s) , m_primaryCodec(NULL) , m_secondaryCodec(NULL) -#if OPAL_VIDEO - , m_rateController(NULL) -#endif { PTRACE_CONTEXT_ID_FROM(p); -#if OPAL_VIDEO - SetRateControlParameters(m_stream->GetMediaFormat()); -#endif - PTRACE(3, "Created Sink for " << p); } @@ -539,9 +532,6 @@ { delete m_primaryCodec; delete m_secondaryCodec; -#if OPAL_VIDEO - delete m_rateController; -#endif } @@ -946,10 +936,6 @@ m_secondaryCodec->UpdateMediaFormats(m_primaryCodec->GetOutputFormat(), m_primaryCodec->GetOutputFormat()) && m_stream->InternalUpdateMediaFormat(m_secondaryCodec->GetOutputFormat()); -#if OPAL_VIDEO - SetRateControlParameters(m_stream->GetMediaFormat()); -#endif - PTRACE(3, "Updated Sink: format=" << mediaFormat << " ok=" << ok); return ok; } @@ -982,70 +968,12 @@ } -#if OPAL_VIDEO -void OpalMediaPatch::Sink::SetRateControlParameters(const OpalMediaFormat & mediaFormat) -{ - if ((mediaFormat.GetMediaType() == OpalMediaType::Video()) && mediaFormat != OpalYUV420P) { - m_rateController = NULL; - PString rc = mediaFormat.GetOptionString(OpalVideoFormat::RateControllerOption()); - if (!rc.IsEmpty()) { - m_rateController = PFactory<OpalVideoRateController>::CreateInstance(rc); - if (m_rateController != NULL) { - PTRACE(3, "Created " << rc << " rate controller"); - } - else { - PTRACE(3, "Could not create " << rc << " rate controller"); - } - } - } - - if (m_rateController != NULL) - m_rateController->Open(mediaFormat); -} - - -bool OpalM... [truncated message content] |
From: <rjo...@us...> - 2016-03-18 18:04:38
|
Revision: 34692 http://sourceforge.net/p/opalvoip/code/34692 Author: rjongbloed Date: 2016-03-18 18:04:37 +0000 (Fri, 18 Mar 2016) Log Message: ----------- Added template specialisation for PSafeSingleton<> Modified Paths: -------------- ptlib/trunk/include/ptlib/atomic.h Modified: ptlib/trunk/include/ptlib/atomic.h =================================================================== --- ptlib/trunk/include/ptlib/atomic.h 2016-03-16 11:12:42 UTC (rev 34691) +++ ptlib/trunk/include/ptlib/atomic.h 2016-03-18 18:04:37 UTC (rev 34692) @@ -262,6 +262,14 @@ bool TestAndSet(bool value) { return exchange(value); } }; + +// Template class for thread safe singleton +template <class Type, Type * (*Creator)() = PSingletonCreatorDefault<Type> > +class PSafeSingleton : public PSingleton<Type, atomic<unsigned>, Creator> +{ +}; + + #endif // PTLIB_CRITICALSECTION_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-16 11:12:44
|
Revision: 34691 http://sourceforge.net/p/opalvoip/code/34691 Author: rjongbloed Date: 2016-03-16 11:12:42 +0000 (Wed, 16 Mar 2016) Log Message: ----------- Added Opus media format source file for Unix build. Modified Paths: -------------- opal/trunk/make/toplevel.mak Modified: opal/trunk/make/toplevel.mak =================================================================== --- opal/trunk/make/toplevel.mak 2016-03-16 10:51:18 UTC (rev 34690) +++ opal/trunk/make/toplevel.mak 2016-03-16 11:12:42 UTC (rev 34691) @@ -422,6 +422,7 @@ $(OPAL_SRCDIR)/codec/gsmamrmf.cxx \ $(OPAL_SRCDIR)/codec/iLBCmf.cxx \ $(OPAL_SRCDIR)/codec/speexmf.cxx \ + $(OPAL_SRCDIR)/codec/opusmf.cxx \ $(OPAL_SRCDIR)/codec/t38mf.cxx \ $(OPAL_SRCDIR)/codec/rfc2833.cxx \ $(OPAL_SRCDIR)/codec/opalwavfile.cxx \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-16 10:51:21
|
Revision: 34690 http://sourceforge.net/p/opalvoip/code/34690 Author: rjongbloed Date: 2016-03-16 10:51:18 +0000 (Wed, 16 Mar 2016) Log Message: ----------- Fixed GNU warning Modified Paths: -------------- opal/trunk/src/opal/mediafmt.cxx Modified: opal/trunk/src/opal/mediafmt.cxx =================================================================== --- opal/trunk/src/opal/mediafmt.cxx 2016-03-15 16:01:05 UTC (rev 34689) +++ opal/trunk/src/opal/mediafmt.cxx 2016-03-16 10:51:18 UTC (rev 34690) @@ -1851,7 +1851,10 @@ OpalAudioFormat::FrameType OpalAudioFormat::GetFrameType(const BYTE * payloadPtr, PINDEX payloadSize, FrameDetectorPtr & detector) const { PWaitAndSignal m(m_mutex); - return m_info == NULL ? e_UnknownFrameType : dynamic_cast<OpalAudioFormatInternal *>(m_info)->GetFrameType(payloadPtr, payloadSize, detector); + if (m_info == NULL) + return e_UnknownFrameType; + + return dynamic_cast<OpalAudioFormatInternal *>(m_info)->GetFrameType(payloadPtr, payloadSize, detector); } @@ -2024,7 +2027,10 @@ OpalVideoFormat::FrameType OpalVideoFormat::GetFrameType(const BYTE * payloadPtr, PINDEX payloadSize, FrameDetectorPtr & detector) const { PWaitAndSignal m(m_mutex); - return m_info == NULL ? e_UnknownFrameType : dynamic_cast<OpalVideoFormatInternal *>(m_info)->GetFrameType(payloadPtr, payloadSize, detector); + if (m_info == NULL) + return e_UnknownFrameType; + + return dynamic_cast<OpalVideoFormatInternal *>(m_info)->GetFrameType(payloadPtr, payloadSize, detector); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-15 16:01:08
|
Revision: 34689 http://sourceforge.net/p/opalvoip/code/34689 Author: rjongbloed Date: 2016-03-15 16:01:05 +0000 (Tue, 15 Mar 2016) Log Message: ----------- Added OpalMediaFormat function to determine certain audio attributes from packet, e.g. silence/VAD. As similar to current function that determines video Intra/Inter frame types, both are normalised to use the same technique, e.g. factory for extensibility. Modified Paths: -------------- opal/trunk/include/codec/known.h opal/trunk/include/codec/vidcodec.h opal/trunk/include/opal/mediafmt.h opal/trunk/include/opal/patch.h opal/trunk/plugins/audio/Opus/OpusCodec.cpp opal/trunk/samples/codectest/main.cxx opal/trunk/src/codec/h263mf.cxx opal/trunk/src/codec/h264mf.cxx opal/trunk/src/codec/mpeg4mf.cxx opal/trunk/src/codec/vidcodec.cxx opal/trunk/src/codec/vp8mf.cxx opal/trunk/src/opal/manager.cxx opal/trunk/src/opal/mediafmt.cxx opal/trunk/src/opal/patch.cxx opal/trunk/src/rtp/pcapfile.cxx opal/trunk/src/win32/opal_lib_2013.vcxproj opal/trunk/src/win32/opal_lib_2013.vcxproj.filters opal/trunk/version.h Added Paths: ----------- opal/trunk/src/codec/opusmf.cxx opal/trunk/src/codec/opusmf_inc.cxx Modified: opal/trunk/include/codec/known.h =================================================================== --- opal/trunk/include/codec/known.h 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/include/codec/known.h 2016-03-15 16:01:05 UTC (rev 34689) @@ -87,6 +87,16 @@ #define OPAL_iLBC "iLBC" #define OPAL_SPEEX_NB "SpeexNB" #define OPAL_SPEEX_WB "SpeexWB" +#define OPAL_OPUS8 "Opus-8" +#define OPAL_OPUS8S "Opus-8S" +#define OPAL_OPUS12 "Opus-12" +#define OPAL_OPUS12S "Opus-12S" +#define OPAL_OPUS16 "Opus-16" +#define OPAL_OPUS16S "Opus-16S" +#define OPAL_OPUS24 "Opus-24" +#define OPAL_OPUS24S "Opus-24S" +#define OPAL_OPUS48 "Opus-48" +#define OPAL_OPUS48S "Opus-48S" #define OPAL_RGB24 "RGB24" #define OPAL_RGB32 "RGB32" Modified: opal/trunk/include/codec/vidcodec.h =================================================================== --- opal/trunk/include/codec/vidcodec.h 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/include/codec/vidcodec.h 2016-03-15 16:01:05 UTC (rev 34689) @@ -217,12 +217,6 @@ RTP_DataFrame & output ///< Output data ); - static OpalVideoFormat::VideoFrameType GetVideoFrameType( - const PCaselessString & rtpEncodingName, - const BYTE * payloadPtr, - PINDEX payloadSize, - PBYTEArray & context - ); virtual bool HasErrorConcealment() const { return m_errorConcealment; } bool WasLastFrameIFrame() const { return m_lastFrameWasIFrame; } Modified: opal/trunk/include/opal/mediafmt.h =================================================================== --- opal/trunk/include/opal/mediafmt.h 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/include/opal/mediafmt.h 2016-03-15 16:01:05 UTC (rev 34689) @@ -1367,26 +1367,6 @@ }; -class OpalAudioFormatInternal : public OpalMediaFormatInternal -{ - public: - OpalAudioFormatInternal( - const char * fullName, - RTP_DataFrame::PayloadTypes rtpPayloadType, - const char * encodingName, - PINDEX frameSize, - unsigned frameTime, - unsigned rxFrames, - unsigned txFrames, - unsigned maxFrames, - unsigned clockRate, - time_t timeStamp = 0, - unsigned channels = 1 - ); - virtual PObject * Clone() const; - virtual bool Merge(const OpalMediaFormatInternal & mediaFormat); -}; - class OpalAudioFormat : public OpalMediaFormat { PCLASSINFO(OpalAudioFormat, OpalMediaFormat); @@ -1419,8 +1399,51 @@ static const PString & MinPacketTimeOption(); static const PString & MaxPacketTimeOption(); #endif + + P_DECLARE_BITWISE_ENUM(FrameType, 3, ( + e_UnknownFrameType, + e_NormalFrame, + e_SilenceFrame, + e_FECFrame + )); + + class FrameDetector + { + protected: + FrameDetector() { } + public: + virtual ~FrameDetector() { } + virtual FrameType GetFrameType(const BYTE * rtp, PINDEX size, unsigned sampleRate) = 0; + }; + typedef std::auto_ptr<FrameDetector> FrameDetectorPtr; + typedef PFactory<FrameDetector, PCaselessString> FrameDetectFactory; + + FrameType GetFrameType(const BYTE * payloadPtr, PINDEX payloadSize, FrameDetectorPtr & detector) const; }; +class OpalAudioFormatInternal : public OpalMediaFormatInternal +{ + public: + OpalAudioFormatInternal( + const char * fullName, + RTP_DataFrame::PayloadTypes rtpPayloadType, + const char * encodingName, + PINDEX frameSize, + unsigned frameTime, + unsigned rxFrames, + unsigned txFrames, + unsigned maxFrames, + unsigned clockRate, + time_t timeStamp = 0, + unsigned channels = 1 + ); + virtual PObject * Clone() const; + virtual bool Merge(const OpalMediaFormatInternal & mediaFormat); + + virtual OpalAudioFormat::FrameType GetFrameType(const BYTE * payloadPtr, PINDEX payloadSize, OpalAudioFormat::FrameDetectorPtr & detector) const; +}; + + #if OPAL_VIDEO class OpalVideoFormatInternal; @@ -1494,13 +1517,25 @@ static const PString & UseImageAttributeInSDP(); #endif // OPAL_SDP - enum VideoFrameType { + enum FrameType { e_UnknownFrameType, e_NonFrameBoundary, e_IntraFrame, e_InterFrame }; - VideoFrameType GetVideoFrameType(const BYTE * payloadPtr, PINDEX payloadSize, PBYTEArray & context) const; + + class FrameDetector + { + protected: + FrameDetector() { } + public: + virtual ~FrameDetector() { } + virtual FrameType GetFrameType(const BYTE * rtp, PINDEX size) = 0; + }; + typedef std::auto_ptr<FrameDetector> FrameDetectorPtr; + typedef PFactory<FrameDetector, PCaselessString> FrameDetectFactory; + + FrameType GetFrameType(const BYTE * payloadPtr, PINDEX payloadSize, FrameDetectorPtr & detector) const; }; class OpalVideoFormatInternal : public OpalMediaFormatInternal @@ -1518,7 +1553,8 @@ ); virtual PObject * Clone() const; virtual bool Merge(const OpalMediaFormatInternal & mediaFormat); - virtual OpalVideoFormat::VideoFrameType GetVideoFrameType(const BYTE * payloadPtr, PINDEX payloadSize, PBYTEArray & context) const; + + virtual OpalVideoFormat::FrameType GetFrameType(const BYTE * payloadPtr, PINDEX payloadSize, OpalVideoFormat::FrameDetectorPtr & detector) const; }; #endif // OPAL_VIDEO @@ -1578,6 +1614,16 @@ extern const OpalAudioFormat & GetOpaliLBC(); extern const OpalAudioFormat & GetOpalSpeexNB(); extern const OpalAudioFormat & GetOpalSpeexWB(); +extern const OpalAudioFormat & GetOpalOpus8(); +extern const OpalAudioFormat & GetOpalOpus8S(); +extern const OpalAudioFormat & GetOpalOpus12(); +extern const OpalAudioFormat & GetOpalOpus12S(); +extern const OpalAudioFormat & GetOpalOpus16(); +extern const OpalAudioFormat & GetOpalOpus16S(); +extern const OpalAudioFormat & GetOpalOpus24(); +extern const OpalAudioFormat & GetOpalOpus24S(); +extern const OpalAudioFormat & GetOpalOpus48(); +extern const OpalAudioFormat & GetOpalOpus48S(); #if OPAL_VIDEO extern const OpalVideoFormat & GetOpalH261(); @@ -1647,6 +1693,17 @@ #define OpaliLBC GetOpaliLBC() #define OpalSpeexNB GetOpalSpeexNB() #define OpalSpeexWB GetOpalSpeexWB() +#define OpalOpus8 GetOpalOpus8() +#define OpalOpus8S GetOpalOpus8S() +#define OpalOpus12 GetOpalOpus12() +#define OpalOpus12S GetOpalOpus12S() +#define OpalOpus16 GetOpalOpus16() +#define OpalOpus16S GetOpalOpus16S() +#define OpalOpus24 GetOpalOpus24() +#define OpalOpus24S GetOpalOpus24S() +#define OpalOpus48 GetOpalOpus48() +#define OpalOpus48S GetOpalOpus48S() + #define OpalRFC2833 GetOpalRFC2833() #define OpalCiscoNSE GetOpalCiscoNSE() #define OpalT38 GetOpalT38() Modified: opal/trunk/include/opal/patch.h =================================================================== --- opal/trunk/include/opal/patch.h 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/include/opal/patch.h 2016-03-15 16:01:05 UTC (rev 34689) @@ -280,7 +280,7 @@ #if OPAL_STATISTICS OpalVideoFormat m_videoFormat; - PBYTEArray m_keyFrameDetectContext; + OpalVideoFormat::FrameDetectorPtr m_keyFrameDetector; typedef map<RTP_SyncSourceId, OpalVideoStatistics> VideoStatsMap; VideoStatsMap m_videoStatistics; PDECLARE_MUTEX(m_videoStatsMutex); Modified: opal/trunk/plugins/audio/Opus/OpusCodec.cpp =================================================================== --- opal/trunk/plugins/audio/Opus/OpusCodec.cpp 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/plugins/audio/Opus/OpusCodec.cpp 2016-03-15 16:01:05 UTC (rev 34689) @@ -36,6 +36,8 @@ #include "plugin_config.h" #endif +#include "../../../src/codec/opusmf_inc.cxx" + #include "opus.h" #include <vector> @@ -80,77 +82,74 @@ ); -#define MAX_BIT_RATE 510000 - - /////////////////////////////////////////////////////////////////////////////// static struct PluginCodec_Option const UseInBandFEC = { PluginCodec_BoolOption, - "Use In-Band FEC", + UseInBandFEC_OptionName, false, PluginCodec_AndMerge, - "1", - "useinbandfec" + STRINGIZE(DEFAULT_USE_FEC), + UseInBandFEC_FMTPName }; static struct PluginCodec_Option const UseDTX = { PluginCodec_BoolOption, - "Use DTX", + UseDTX_OptionName, false, PluginCodec_AndMerge, - "0", - "usedtx" + STRINGIZE(DEFAULT_USE_DTX), + UseDTX_FMTPName }; static struct PluginCodec_Option const MaxPlaybackRate = { PluginCodec_IntegerOption, - "Max Playback Rate", + MaxPlaybackRate_OptionName, true, PluginCodec_NoMerge, - "64000", - "maxplaybackrate", + STRINGIZE(DEFAULT_BIT_RATE), + MaxPlaybackRate_FMTPName, "", 0, - "6000", + STRINGIZE(MIN_BIT_RATE), STRINGIZE(MAX_BIT_RATE) }; static struct PluginCodec_Option const MaxCaptureRate = { PluginCodec_IntegerOption, - "Max Capture Rate", + MaxCaptureRate_OptionName, true, PluginCodec_NoMerge, - "64000", - "sprop-maxcapturerate", + STRINGIZE(DEFAULT_BIT_RATE), + MaxCaptureRate_FMTPName, "", 0, - "6000", + STRINGIZE(MIN_BIT_RATE), STRINGIZE(MAX_BIT_RATE) }; static struct PluginCodec_Option const PlaybackStereo = { PluginCodec_BoolOption, - "Playback Stereo", + PlaybackStereo_OptionName, true, PluginCodec_NoMerge, - "0", - "stereo" + STRINGIZE(DEFAULT_STEREO), + PlaybackStereo_FMTPName }; static struct PluginCodec_Option const CaptureStereo = { PluginCodec_BoolOption, - "Capture Stereo", + CaptureStereo_OptionName, true, PluginCodec_NoMerge, - "0", - "sprop-stereo" + STRINGIZE(DEFAULT_STEREO), + CaptureStereo_FMTPName }; static struct PluginCodec_Option const DynamicPacketLoss = @@ -163,8 +162,7 @@ NULL, NULL, 0, - "0", - "100" + "0","100" // percentage }; static struct PluginCodec_Option const * const MyOptions[] = { @@ -186,16 +184,16 @@ unsigned m_actualChannels; OpusPluginMediaFormat(const char * formatName, const char * rawFormat, unsigned actualSampleRate, unsigned actualChannels) - : PluginCodec_AudioFormat<MY_CODEC>(formatName, "OPUS", MyDescription, - 960*actualChannels*actualSampleRate/48000, - MAX_BIT_RATE*20/1000/8, // 20ms and bits to bytes - 48000, MyOptions) + : PluginCodec_AudioFormat<MY_CODEC>(formatName, OpusEncodingName, MyDescription, + 960*actualChannels*actualSampleRate/OPUS_SAMPLE_RATE, + MAX_BIT_RATE*OPUS_FRAME_MS/1000/8, // 20ms and bits to bytes + OPUS_SAMPLE_RATE, MyOptions) , m_actualSampleRate(actualSampleRate) , m_actualChannels(actualChannels) { m_rawFormat = rawFormat; m_recommendedFramesPerPacket = 1; // 20ms - m_maxFramesPerPacket = 6; // 120ms + m_maxFramesPerPacket = 120/OPUS_FRAME_MS; // 120ms m_maxBandwidth = MAX_BIT_RATE; m_frameTime = 20000; // Rare occasion where frame time not derived from samplesPerFrame and sampleRate m_flags |= PluginCodec_SetChannels(2) | PluginCodec_RTPTypeShared | PluginCodec_EmptyPayload; @@ -223,7 +221,7 @@ #define CHANNEL 1 #define CHANNELS 2 #define DEF_MEDIA_FORMAT(rate, stereo) \ - static OpusPluginMediaFormat const MyMediaFormat##rate##stereo("Opus-" #rate #stereo, \ + static OpusPluginMediaFormat const MyMediaFormat##rate##stereo(OPAL_OPUS##rate##stereo, \ OPAL_PCM16##stereo##_##rate##KHZ, rate*1000, CHANNEL##stereo) DEF_MEDIA_FORMAT( 8, ); DEF_MEDIA_FORMAT( 8,S); Modified: opal/trunk/samples/codectest/main.cxx =================================================================== --- opal/trunk/samples/codectest/main.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/samples/codectest/main.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -945,8 +945,10 @@ RTP_DataFrame srcFrame; + OpalAudioFormat audioFormat(m_encoder->GetOutputFormat()); + OpalAudioFormat::FrameDetectorPtr audioDetector; OpalVideoFormat videoFormat(m_encoder->GetOutputFormat()); - PBYTEArray videoDetectorContext; + OpalVideoFormat::FrameDetectorPtr videoDetector; bool videoDetectorFailed = false; while ((m_running && m_framesToTranscode < 0) || (m_framesToTranscode-- > 0)) { @@ -1152,7 +1154,7 @@ if (isVideo) { bool detectedInter = false; for (PINDEX i = 0; i < encFrames.GetSize(); i++) { - switch (videoFormat.GetVideoFrameType(encFrames[i].GetPayloadPtr(), encFrames[i].GetPayloadSize(), videoDetectorContext)) { + switch (videoFormat.GetFrameType(encFrames[i].GetPayloadPtr(), encFrames[i].GetPayloadSize(), videoDetector)) { case OpalVideoFormat::e_IntraFrame : detectorSaysIntra = true; break; @@ -1170,6 +1172,16 @@ coutMutex.Signal(); } } + else { + for (PINDEX i = 0; i < encFrames.GetSize(); i++) { + OpalAudioFormat::FrameType type = audioFormat.GetFrameType(encFrames[i].GetPayloadPtr(), encFrames[i].GetPayloadSize(), audioDetector); + if (type & OpalAudioFormat::e_SilenceFrame) { + coutMutex.Wait(); + cout << "Audio frame silent." << endl; + coutMutex.Signal(); + } + } + } } ////////////////////////////////////////////// Modified: opal/trunk/src/codec/h263mf.cxx =================================================================== --- opal/trunk/src/codec/h263mf.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/codec/h263mf.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -224,6 +224,68 @@ return format; } + +struct OpalKeyFrameDetectorH263 : OpalVideoFormat::FrameDetector +{ + virtual OpalVideoFormat::FrameType GetFrameType(const BYTE * rtp, PINDEX size) + { + if (size < 8) + return OpalVideoFormat::e_UnknownFrameType; + + if ((rtp[4] & 0x1c) != 0x1c) + return (rtp[4] & 2) != 0 ? OpalVideoFormat::e_InterFrame : OpalVideoFormat::e_IntraFrame; + + switch (((rtp[5] & 0x80) != 0 ? (rtp[7] >> 2) : (rtp[5] >> 5)) & 3) { + case 0: + case 4: + return OpalVideoFormat::e_IntraFrame; + case 1: + case 5: + return OpalVideoFormat::e_InterFrame; + } + return OpalVideoFormat::e_NonFrameBoundary; + } +}; + + +struct OpalKeyFrameDetectorRFC2190 : OpalKeyFrameDetectorH263 +{ + virtual OpalVideoFormat::FrameType GetFrameType(const BYTE * rtp, PINDEX size) + { + // RFC 2190 header length + static const PINDEX ModeLen[4] = { 4, 4, 8, 12 }; + PINDEX len = ModeLen[(rtp[0] & 0xC0) >> 6]; + if (size < len + 6) + return OpalVideoFormat::e_UnknownFrameType; + + rtp += len; + if (rtp[0] != 0 || rtp[1] != 0 || (rtp[2] & 0xfc) != 0x80) + return OpalVideoFormat::e_NonFrameBoundary; + + return OpalKeyFrameDetectorH263::GetFrameType(rtp, size); + } +}; + +PFACTORY_CREATE(OpalVideoFormat::FrameDetectFactory, OpalKeyFrameDetectorRFC2190, "H263"); + + +struct OpalKeyFrameDetectorRFC4629 : OpalKeyFrameDetectorH263 +{ + virtual OpalVideoFormat::FrameType GetFrameType(const BYTE * rtp, PINDEX size) + { + if (size < 6) + return OpalVideoFormat::e_UnknownFrameType; + + if ((rtp[0] & 0xfd) != 4 || rtp[1] != 0 || (rtp[2] & 0xfc) != 0x80) + return OpalVideoFormat::e_NonFrameBoundary; + + return OpalKeyFrameDetectorH263::GetFrameType(rtp, size); + } +}; + +PFACTORY_CREATE(OpalVideoFormat::FrameDetectFactory, OpalKeyFrameDetectorRFC4629, "H263-1998"); + + #endif // OPAL_VIDEO // End of File /////////////////////////////////////////////////////////////// Modified: opal/trunk/src/codec/h264mf.cxx =================================================================== --- opal/trunk/src/codec/h264mf.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/codec/h264mf.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -209,6 +209,47 @@ } +struct OpalKeyFrameDetectorH264 : OpalVideoFormat::FrameDetector +{ + bool m_gotSPS; + bool m_gotPPS; + + virtual OpalVideoFormat::FrameType GetFrameType(const BYTE * rtp, PINDEX size) + { + if (size > 2) { + switch ((*rtp++) & 0x1f) { + case 1: // Coded slice of a non-IDR picture + case 2: // Coded slice data partition A + if ((*rtp & 0x80) != 0) // High bit 1 indicates MB zero + return OpalVideoFormat::e_InterFrame; + break; + + case 5: // Coded slice of an IDR picture + if (m_gotSPS && m_gotPPS && (*rtp & 0x80) != 0) // High bit 1 indicates MB zero + return OpalVideoFormat::e_IntraFrame; + break; + + case 7: // Sequence parameter set + m_gotSPS = *rtp == 66 || *rtp == 77 || *rtp == 88 || *rtp == 100; + return OpalVideoFormat::e_NonFrameBoundary; + + case 8: // Picture parameter set + m_gotPPS = true; + return OpalVideoFormat::e_NonFrameBoundary; + + case 28: // Fragment + if ((*rtp & 0x80) != 0) + return GetFrameType(rtp, size - 1); + } + } + + return OpalVideoFormat::e_NonFrameBoundary; + } +}; + +PFACTORY_CREATE(OpalVideoFormat::FrameDetectFactory, OpalKeyFrameDetectorH264, "H264"); + + #endif // OPAL_VIDEO Modified: opal/trunk/src/codec/mpeg4mf.cxx =================================================================== --- opal/trunk/src/codec/mpeg4mf.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/codec/mpeg4mf.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -125,6 +125,35 @@ } +struct OpalKeyFrameDetectorMPEG4 : OpalVideoFormat::FrameDetector +{ + virtual OpalVideoFormat::FrameType GetFrameType(const BYTE * rtp, PINDEX size) + { + if (size < 4 || rtp[0] != 0 || rtp[1] != 0 || rtp[2] != 1) + return OpalVideoFormat::e_UnknownFrameType; + + while (size > 4) { + if (rtp[0] == 0 && rtp[1] == 0 && rtp[2] == 1) { + if (rtp[3] == 0xb6) { + switch ((rtp[4] & 0xC0) >> 6) { + case 0: + return OpalVideoFormat::e_IntraFrame; + case 1: + return OpalVideoFormat::e_InterFrame; + } + } + } + ++rtp; + --size; + } + + return OpalVideoFormat::e_NonFrameBoundary; + } +}; + +PFACTORY_CREATE(OpalVideoFormat::FrameDetectFactory, OpalKeyFrameDetectorMPEG4, "MP4V-ES"); + + #endif // OPAL_VIDEO Added: opal/trunk/src/codec/opusmf.cxx =================================================================== --- opal/trunk/src/codec/opusmf.cxx (rev 0) +++ opal/trunk/src/codec/opusmf.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -0,0 +1,257 @@ +/* + * opusmf.cxx + * + * Opus Media Format descriptions + * + * Open Phone Abstraction Library + * Formally known as the Open H323 project. + * + * Copyright (c) 2008 Vox Lucida + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Open Phone Abstraction Library + * + * The Initial Developer of the Original Code is Vox Lucida + * + * Contributor(s): ______________________________________. + * + * $Revision$ + * $Author$ + * $Date$ + */ + +#include <ptlib.h> + +#include "opusmf_inc.cxx" + +#include <opal/mediafmt.h> +#include <codec/opalplugin.h> +//#include <h323/h323caps.h> + + +class OpalOpusFormat : public OpalAudioFormatInternal +{ + public: + OpalOpusFormat(const char * formatName, unsigned sampleRate, unsigned channels) + : OpalAudioFormatInternal(formatName, + RTP_DataFrame::DynamicBase, + OpusEncodingName, + MAX_BIT_RATE*OPUS_FRAME_MS/1000/8, + OPUS_FRAME_MS, + 1, 1, 1, + sampleRate, 0, channels) + { + OpalMediaOption * option; + +#if OPAL_SDP + option = new OpalMediaOptionBoolean(UseInBandFEC_OptionName, true, OpalMediaOption::AndMerge, DEFAULT_USE_DTX); + option->SetFMTP(UseInBandFEC_FMTPName, NULL); + AddOption(option); + + option = new OpalMediaOptionBoolean(UseDTX_OptionName, true, OpalMediaOption::AndMerge, DEFAULT_USE_DTX); + option->SetFMTP(UseDTX_FMTPName, NULL); + AddOption(option); + + option = new OpalMediaOptionInteger(MaxPlaybackRate_OptionName, true, OpalMediaOption::MinMerge, DEFAULT_BIT_RATE, MIN_BIT_RATE, MAX_BIT_RATE); + option->SetFMTP(MaxPlaybackRate_FMTPName, NULL); + AddOption(option); + + option = new OpalMediaOptionInteger(MaxCaptureRate_OptionName, true, OpalMediaOption::MinMerge, DEFAULT_BIT_RATE, MIN_BIT_RATE, MAX_BIT_RATE); + option->SetFMTP(MaxCaptureRate_FMTPName, NULL); + AddOption(option); + + option = new OpalMediaOptionBoolean(PlaybackStereo_OptionName, true, OpalMediaOption::AndMerge, DEFAULT_STEREO); + option->SetFMTP(PlaybackStereo_FMTPName, NULL); + AddOption(option); + + option = new OpalMediaOptionBoolean(CaptureStereo_OptionName, true, OpalMediaOption::AndMerge, DEFAULT_STEREO); + option->SetFMTP(CaptureStereo_FMTPName, NULL); + AddOption(option); +#endif + } + + + virtual PObject * Clone() const + { + return new OpalOpusFormat(*this); + } +}; + + +#define CHANNEL 1 +#define CHANNELS 2 +#define DEF_MEDIA_FORMAT(rate,stereo) \ + const OpalAudioFormat & GetOpalOpus##rate##stereo() \ + { \ + static OpalAudioFormat const plugin("Opus-" #rate #stereo); if (plugin.IsValid()) return plugin; \ + static OpalAudioFormat const format(new OpalOpusFormat(OPAL_OPUS##rate##stereo, rate*1000, CHANNEL##stereo)); \ + return format; \ + } + +DEF_MEDIA_FORMAT( 8, ); +DEF_MEDIA_FORMAT( 8,S); +DEF_MEDIA_FORMAT(12, ); +DEF_MEDIA_FORMAT(12,S); +DEF_MEDIA_FORMAT(16, ); +DEF_MEDIA_FORMAT(16,S); +DEF_MEDIA_FORMAT(24, ); +DEF_MEDIA_FORMAT(24,S); +DEF_MEDIA_FORMAT(48, ); +DEF_MEDIA_FORMAT(48,S); + + +struct OpalAudioFrameDetectorOpus : OpalAudioFormat::FrameDetector +{ + static const BYTE * ParseFramePtr(const BYTE * & payloadPtr, PINDEX & payloadLen) + { + if (payloadLen < 1) + return NULL; + + const BYTE * framePtr; + PINDEX frameLen; + if (payloadPtr[0] < 252) { + frameLen = payloadPtr[0]; + framePtr = ++payloadPtr; + --payloadLen; + } + else { + if (payloadLen < 2) + return NULL; + + frameLen = 4 * payloadPtr[1] + payloadPtr[0]; + framePtr = payloadPtr += 2; + payloadLen -= 2; + } + + if (frameLen == 0 || frameLen > payloadLen) + return NULL; + + payloadPtr += frameLen; + payloadLen -= frameLen; + return framePtr; + } + + virtual OpalAudioFormat::FrameType GetFrameType(const BYTE * payloadPtr, PINDEX payloadLen, unsigned sampleRate) + { + if (payloadLen < 2) + return OpalAudioFormat::e_UnknownFrameType; + + unsigned toc = *payloadPtr++; + --payloadLen; + + // In CELT_ONLY mode, packets does not have VAD. + if (toc & 0x80) + return OpalAudioFormat::e_NormalFrame; + + unsigned channels = (toc & 0x4) ? 2 : 1; + + unsigned subFrames; + if ((toc & 0x60) == 0x60) + subFrames = 1; + else { + subFrames = ((toc >> 3) & 0x3); + if (subFrames != 3) + subFrames = ((sampleRate << subFrames) * 10 / sampleRate + 19) / 20; + } + + + PINDEX frameCount; + static unsigned const MaxFrames = 6; + const BYTE * framePtr[MaxFrames]; + switch (toc & 0x3) { + case 0: + frameCount = 1; + framePtr[0] = payloadPtr; + break; + + case 1: // Two CBR frames + frameCount = 2; + if (payloadLen & 1) + return OpalAudioFormat::e_UnknownFrameType; + framePtr[0] = payloadPtr; + framePtr[1] = payloadPtr + payloadLen / 2; + break; + + case 2: // Two VBR frames + frameCount = 2; + if ((framePtr[0] = ParseFramePtr(payloadPtr, payloadLen)) == NULL) + return OpalAudioFormat::e_UnknownFrameType; + framePtr[1] = payloadPtr; + break; + + default: // Multiple CBR/VBR frames (from 0 to 120 ms) + if (--payloadLen == 0) + return OpalAudioFormat::e_UnknownFrameType; + unsigned toc2 = *payloadPtr++; + + frameCount = toc2 & 0x3F; // Number of frames encoded in bits 0 to 5 + if (frameCount <= 0 || frameCount > MaxFrames) + return OpalAudioFormat::e_UnknownFrameType; + + if (toc2 & 0x40) { // Padding flag is bit 6 + PINDEX totalPad = 0; + for (;;) { + if (--payloadLen == 0) + return OpalAudioFormat::e_UnknownFrameType; + unsigned padByte = *payloadPtr++; + if (padByte != 255) { + totalPad += padByte; + break; + } + totalPad += 254; + } + + if (payloadLen < totalPad) + return OpalAudioFormat::e_UnknownFrameType; + payloadLen -= totalPad; + } + + if (toc2 & 0x80) { + // VBR case + for (PINDEX i = 0; i < frameCount; i++) { + if ((framePtr[i] = ParseFramePtr(payloadPtr, payloadLen)) == NULL) + return OpalAudioFormat::e_UnknownFrameType; + } + } + else { + // CBR case + PINDEX frameSize = payloadLen/frameCount; + if (frameSize*frameCount != frameCount) + return OpalAudioFormat::e_UnknownFrameType; + for (PINDEX i = 0; i < frameCount; i++) + framePtr[i] = payloadPtr+frameSize*i; + } + } + + bool vad = false; + OpalAudioFormat::FrameType frameType = OpalAudioFormat::e_NormalFrame; + for (PINDEX frame = 0; frame < frameCount; ++frame) { + for (unsigned chan = 0; chan < channels; chan++) { + // Highest "subFrames" bits are VAD, next bit is LBRR flag, repeated for each channel + unsigned offset = (subFrames+1)*chan; + if (framePtr[frame][0] & (0x80 >> (offset + subFrames))) + frameType |= OpalAudioFormat::e_FECFrame; + if (framePtr[frame][0] & (((0xFF << (8-subFrames))&0xFF) >> offset)) + vad = true; + } + } + + if (!vad) + frameType |= OpalAudioFormat::e_SilenceFrame; + return frameType; + } +}; + +PFACTORY_CREATE(OpalAudioFormat::FrameDetectFactory, OpalAudioFrameDetectorOpus, "OPUS"); + + +// End of File /////////////////////////////////////////////////////////////// Property changes on: opal/trunk/src/codec/opusmf.cxx ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: opal/trunk/src/codec/opusmf_inc.cxx =================================================================== --- opal/trunk/src/codec/opusmf_inc.cxx (rev 0) +++ opal/trunk/src/codec/opusmf_inc.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -0,0 +1,65 @@ +/* + * opusmf_inc.cxx + * + * Opus Media Format descriptions + * + * Open Phone Abstraction Library + * Formally known as the Open H323 project. + * + * Copyright (c) 2008 Vox Lucida + * + * The contents of this file are subject to the Mozilla Public License + * Version 1.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See + * the License for the specific language governing rights and limitations + * under the License. + * + * The Original Code is Open Phone Abstraction Library + * + * The Initial Developer of the Original Code is Vox Lucida + * + * Contributor(s): ______________________________________. + * + * $Revision$ + * $Author$ + * $Date$ + */ + +#include <codec/opalplugin.h> +#include <codec/known.h> + + +/////////////////////////////////////////////////////////////////////////////// + +static const char OpusEncodingName[] = "OPUS"; // MIME name rfc's 3047, 5577 + +static const char UseInBandFEC_OptionName[] = "Use In-Band FEC"; +static const char UseInBandFEC_FMTPName[] = "useinbandfec"; +static const char UseDTX_OptionName[] = "Use DTX"; +static const char UseDTX_FMTPName[] = "usedtx"; +static const char MaxPlaybackRate_OptionName[] = "Max Playback Rate"; +static const char MaxPlaybackRate_FMTPName[] = "maxplaybackrate"; +static const char MaxCaptureRate_OptionName[] = "Max Capture Rate"; +static const char MaxCaptureRate_FMTPName[] = "sprop-maxcapturerate"; +static const char PlaybackStereo_OptionName[] = "Playback Stereo"; +static const char PlaybackStereo_FMTPName[] = "stereo"; +static const char CaptureStereo_OptionName[] = "Capture Stereo"; +static const char CaptureStereo_FMTPName[] = "sprop-stereo"; + +#define OPUS_FRAME_MS 20 +#define OPUS_SAMPLE_RATE 48000 + +#define MIN_BIT_RATE 6000 +#define MAX_BIT_RATE 510000 + +#define DEFAULT_BIT_RATE 64000 +#define DEFAULT_USE_FEC 1 +#define DEFAULT_USE_DTX 0 +#define DEFAULT_STEREO 0 + + +// End of File /////////////////////////////////////////////////////////////// Property changes on: opal/trunk/src/codec/opusmf_inc.cxx ___________________________________________________________________ Added: svn:keywords ## -0,0 +1 ## +Author Date Revision \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: opal/trunk/src/codec/vidcodec.cxx =================================================================== --- opal/trunk/src/codec/vidcodec.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/codec/vidcodec.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -374,206 +374,6 @@ /////////////////////////////////////////////////////////////////////////////// -// This should really do the key frame detection from the codec plugin, but we cheat for now -struct OpalKeyFrameDetector -{ - template <class T> static OpalKeyFrameDetector * Create(PBYTEArray & context) - { -#undef new // Doing fancy "in-place" new operator so no malloc() done every time - return new (context.GetPointer(sizeof(T))) T(); -#define new PNEW - } - - virtual ~OpalKeyFrameDetector() - { - } - virtual OpalVideoFormat::VideoFrameType GetVideoFrameType(const BYTE * rtp, PINDEX size) = 0; -} *kfd = NULL; - - -struct OpalKeyFrameDetectorVP8 : OpalKeyFrameDetector -{ - virtual OpalVideoFormat::VideoFrameType GetVideoFrameType(const BYTE * rtp, PINDEX size) - { - if (size < 3) - return OpalVideoFormat::e_NonFrameBoundary; - - PINDEX headerSize = 1; - if ((rtp[0] & 0x80) != 0) { // Check X bit - ++headerSize; // Allow for X byte - - if ((rtp[1] & 0x80) != 0) { // Check I bit - ++headerSize; // Allow for I field - if ((rtp[2] & 0x80) != 0) // > 7 bit picture ID - ++headerSize; // Allow for extra bits of I field - } - - if ((rtp[1] & 0x40) != 0) // Check L bit - ++headerSize; // Allow for L byte - - if ((rtp[1] & 0x30) != 0) // Check T or K bit - ++headerSize; // Allow for T/K byte - } - - if (size <= headerSize) - return OpalVideoFormat::e_NonFrameBoundary; - - // Key frame is S bit == 1 && partition == 0 && P bit == 0 - if ((rtp[0]&0x1f) != 0x10) - return OpalVideoFormat::e_NonFrameBoundary; - - return (rtp[headerSize] & 0x01) == 0 ? OpalVideoFormat::e_IntraFrame : OpalVideoFormat::e_InterFrame; - } -}; - - -struct OpalKeyFrameDetectorH264 : OpalKeyFrameDetector -{ - bool m_gotSPS; - bool m_gotPPS; - - virtual OpalVideoFormat::VideoFrameType GetVideoFrameType(const BYTE * rtp, PINDEX size) - { - if (size > 2) { - switch ((*rtp++) & 0x1f) { - case 1: // Coded slice of a non-IDR picture - case 2: // Coded slice data partition A - if ((*rtp & 0x80) != 0) // High bit 1 indicates MB zero - return OpalVideoFormat::e_InterFrame; - break; - - case 5: // Coded slice of an IDR picture - if (m_gotSPS && m_gotPPS && (*rtp & 0x80) != 0) // High bit 1 indicates MB zero - return OpalVideoFormat::e_IntraFrame; - break; - - case 7: // Sequence parameter set - m_gotSPS = *rtp == 66 || *rtp == 77 || *rtp == 88 || *rtp == 100; - return OpalVideoFormat::e_NonFrameBoundary; - - case 8: // Picture parameter set - m_gotPPS = true; - return OpalVideoFormat::e_NonFrameBoundary; - - case 28: // Fragment - if ((*rtp & 0x80) != 0) - return GetVideoFrameType(rtp, size - 1); - } - } - - return OpalVideoFormat::e_NonFrameBoundary; - } -}; - - -struct OpalKeyFrameDetectorMPEG4 : OpalKeyFrameDetector -{ - virtual OpalVideoFormat::VideoFrameType GetVideoFrameType(const BYTE * rtp, PINDEX size) - { - if (size < 4 || rtp[0] != 0 || rtp[1] != 0 || rtp[2] != 1) - return OpalVideoFormat::e_UnknownFrameType; - - while (size > 4) { - if (rtp[0] == 0 && rtp[1] == 0 && rtp[2] == 1) { - if (rtp[3] == 0xb6) { - switch ((rtp[4] & 0xC0) >> 6) { - case 0: - return OpalVideoFormat::e_IntraFrame; - case 1: - return OpalVideoFormat::e_InterFrame; - } - } - } - ++rtp; - --size; - } - - return OpalVideoFormat::e_NonFrameBoundary; - } -}; - - -struct OpalKeyFrameDetectorH263 : OpalKeyFrameDetector -{ - virtual OpalVideoFormat::VideoFrameType GetVideoFrameType(const BYTE * rtp, PINDEX size) - { - if (size < 8) - return OpalVideoFormat::e_UnknownFrameType; - - if ((rtp[4] & 0x1c) != 0x1c) - return (rtp[4] & 2) != 0 ? OpalVideoFormat::e_InterFrame : OpalVideoFormat::e_IntraFrame; - - switch (((rtp[5] & 0x80) != 0 ? (rtp[7] >> 2) : (rtp[5] >> 5)) & 3) { - case 0: - case 4: - return OpalVideoFormat::e_IntraFrame; - case 1: - case 5: - return OpalVideoFormat::e_InterFrame; - } - return OpalVideoFormat::e_NonFrameBoundary; - } -}; - - -struct OpalKeyFrameDetectorRFC2190 : OpalKeyFrameDetectorH263 -{ - virtual OpalVideoFormat::VideoFrameType GetVideoFrameType(const BYTE * rtp, PINDEX size) - { - // RFC 2190 header length - static const PINDEX ModeLen[4] = { 4, 4, 8, 12 }; - PINDEX len = ModeLen[(rtp[0] & 0xC0) >> 6]; - if (size < len + 6) - return OpalVideoFormat::e_UnknownFrameType; - - rtp += len; - if (rtp[0] != 0 || rtp[1] != 0 || (rtp[2] & 0xfc) != 0x80) - return OpalVideoFormat::e_NonFrameBoundary; - - return OpalKeyFrameDetectorH263::GetVideoFrameType(rtp, size); - } -}; - - -struct OpalKeyFrameDetectorRFC4629 : OpalKeyFrameDetectorH263 -{ - virtual OpalVideoFormat::VideoFrameType GetVideoFrameType(const BYTE * rtp, PINDEX size) - { - if (size < 6) - return OpalVideoFormat::e_UnknownFrameType; - - if ((rtp[0] & 0xfd) != 4 || rtp[1] != 0 || (rtp[2] & 0xfc) != 0x80) - return OpalVideoFormat::e_NonFrameBoundary; - - return OpalKeyFrameDetectorH263::GetVideoFrameType(rtp, size); - } -}; - - -OpalVideoFormat::VideoFrameType OpalVideoTranscoder::GetVideoFrameType(const PCaselessString & rtpEncodingName, - const BYTE * payloadPtr, - PINDEX payloadSize, - PBYTEArray & context) -{ - if (!context.IsEmpty()) - kfd = reinterpret_cast<OpalKeyFrameDetector *>(context.GetPointer()); - else if (rtpEncodingName == "VP8") - kfd = OpalKeyFrameDetector::Create<OpalKeyFrameDetectorVP8>(context); - else if (rtpEncodingName == "H264") - kfd = OpalKeyFrameDetector::Create<OpalKeyFrameDetectorH264>(context); - else if (rtpEncodingName == "MP4V-ES") - kfd = OpalKeyFrameDetector::Create<OpalKeyFrameDetectorMPEG4>(context); - else if (rtpEncodingName == "H263") - kfd = OpalKeyFrameDetector::Create<OpalKeyFrameDetectorRFC2190>(context); - else if (rtpEncodingName == "H263-1998") - kfd = OpalKeyFrameDetector::Create<OpalKeyFrameDetectorRFC4629>(context); - - return kfd != NULL ? kfd->GetVideoFrameType(payloadPtr, payloadSize) : OpalVideoFormat::e_UnknownFrameType; -} - - -/////////////////////////////////////////////////////////////////////////////// - OpalVideoUpdatePicture::OpalVideoUpdatePicture(unsigned sessionID, unsigned ssrc) : OpalMediaCommand(OpalMediaType::Video(), sessionID, ssrc) { Modified: opal/trunk/src/codec/vp8mf.cxx =================================================================== --- opal/trunk/src/codec/vp8mf.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/codec/vp8mf.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -90,6 +90,44 @@ } +struct OpalKeyFrameDetectorVP8 : OpalVideoFormat::FrameDetector +{ + virtual OpalVideoFormat::FrameType GetFrameType(const BYTE * rtp, PINDEX size) + { + if (size < 3) + return OpalVideoFormat::e_NonFrameBoundary; + + PINDEX headerSize = 1; + if ((rtp[0] & 0x80) != 0) { // Check X bit + ++headerSize; // Allow for X byte + + if ((rtp[1] & 0x80) != 0) { // Check I bit + ++headerSize; // Allow for I field + if ((rtp[2] & 0x80) != 0) // > 7 bit picture ID + ++headerSize; // Allow for extra bits of I field + } + + if ((rtp[1] & 0x40) != 0) // Check L bit + ++headerSize; // Allow for L byte + + if ((rtp[1] & 0x30) != 0) // Check T or K bit + ++headerSize; // Allow for T/K byte + } + + if (size <= headerSize) + return OpalVideoFormat::e_NonFrameBoundary; + + // Key frame is S bit == 1 && partition == 0 && P bit == 0 + if ((rtp[0]&0x1f) != 0x10) + return OpalVideoFormat::e_NonFrameBoundary; + + return (rtp[headerSize] & 0x01) == 0 ? OpalVideoFormat::e_IntraFrame : OpalVideoFormat::e_InterFrame; + } +}; + +PFACTORY_CREATE(OpalVideoFormat::FrameDetectFactory, OpalKeyFrameDetectorVP8, "VP8"); + + #endif // OPAL_VIDEO Modified: opal/trunk/src/opal/manager.cxx =================================================================== --- opal/trunk/src/opal/manager.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/opal/manager.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -64,6 +64,7 @@ static const char * const DefaultMediaFormatOrder[] = { + OPAL_OPUS48, OPAL_G7222, OPAL_G7221_32K, OPAL_G7221_24K, Modified: opal/trunk/src/opal/mediafmt.cxx =================================================================== --- opal/trunk/src/opal/mediafmt.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/opal/mediafmt.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -1145,6 +1145,16 @@ KNOWN(iLBC), KNOWN2(SPEEX_NB, SpeexNB), KNOWN2(SPEEX_WB, SpeexWB), + KNOWN2(OPUS8, Opus8), + KNOWN2(OPUS8S, Opus8S), + KNOWN2(OPUS12, Opus12), + KNOWN2(OPUS12S, Opus12S), + KNOWN2(OPUS16, Opus16), + KNOWN2(OPUS16S, Opus16S), + KNOWN2(OPUS24, Opus24), + KNOWN2(OPUS24S, Opus24S), + KNOWN2(OPUS48, Opus48), + KNOWN2(OPUS48S, Opus48S), #if OPAL_VIDEO KNOWN(H261), KNOWN(H263), @@ -1838,6 +1848,27 @@ } +OpalAudioFormat::FrameType OpalAudioFormat::GetFrameType(const BYTE * payloadPtr, PINDEX payloadSize, FrameDetectorPtr & detector) const +{ + PWaitAndSignal m(m_mutex); + return m_info == NULL ? e_UnknownFrameType : dynamic_cast<OpalAudioFormatInternal *>(m_info)->GetFrameType(payloadPtr, payloadSize, detector); +} + + +OpalAudioFormat::FrameType OpalAudioFormatInternal::GetFrameType(const BYTE * payloadPtr, + PINDEX payloadSize, + OpalAudioFormat::FrameDetectorPtr & detector) const +{ + if (detector.get() == NULL) { + detector.reset(OpalAudioFormat::FrameDetectFactory::CreateInstance(rtpEncodingName)); + if (detector.get() == NULL) + return OpalAudioFormat::e_UnknownFrameType; + } + + return detector->GetFrameType(payloadPtr, payloadSize, GetOptionInteger(OpalMediaFormat::ClockRateOption(), OpalMediaFormat::AudioClockRate)); +} + + /////////////////////////////////////////////////////////////////////////////// #if OPAL_VIDEO @@ -1990,16 +2021,24 @@ } -OpalVideoFormat::VideoFrameType OpalVideoFormat::GetVideoFrameType(const BYTE * payloadPtr, PINDEX payloadSize, PBYTEArray & context) const +OpalVideoFormat::FrameType OpalVideoFormat::GetFrameType(const BYTE * payloadPtr, PINDEX payloadSize, FrameDetectorPtr & detector) const { PWaitAndSignal m(m_mutex); - return m_info == NULL ? e_UnknownFrameType : dynamic_cast<OpalVideoFormatInternal *>(m_info)->GetVideoFrameType(payloadPtr, payloadSize, context); + return m_info == NULL ? e_UnknownFrameType : dynamic_cast<OpalVideoFormatInternal *>(m_info)->GetFrameType(payloadPtr, payloadSize, detector); } -OpalVideoFormat::VideoFrameType OpalVideoFormatInternal::GetVideoFrameType(const BYTE * payloadPtr, PINDEX payloadSize, PBYTEArray & context) const +OpalVideoFormat::FrameType OpalVideoFormatInternal::GetFrameType(const BYTE * payloadPtr, + PINDEX payloadSize, + OpalVideoFormat::FrameDetectorPtr & detector) const { - return OpalVideoTranscoder::GetVideoFrameType(rtpEncodingName, payloadPtr, payloadSize, context); + if (detector.get() == NULL) { + detector.reset(OpalVideoFormat::FrameDetectFactory::CreateInstance(rtpEncodingName)); + if (detector.get() == NULL) + return OpalVideoFormat::e_UnknownFrameType; + } + + return detector->GetFrameType(payloadPtr, payloadSize); } #endif // OPAL_VIDEO Modified: opal/trunk/src/opal/patch.cxx =================================================================== --- opal/trunk/src/opal/patch.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/opal/patch.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -1046,9 +1046,9 @@ } } - OpalVideoFormat::VideoFrameType frameType; + OpalVideoFormat::FrameType frameType; if (m_videoFormat.IsValid()) - frameType = m_videoFormat.GetVideoFrameType(sourceFrame.GetPayloadPtr(), sourceFrame.GetPayloadSize(), m_keyFrameDetectContext); + frameType = m_videoFormat.GetFrameType(sourceFrame.GetPayloadPtr(), sourceFrame.GetPayloadSize(), m_keyFrameDetector); else frameType = OpalVideoFormat::e_UnknownFrameType; #endif // OPAL_VIDEO Modified: opal/trunk/src/rtp/pcapfile.cxx =================================================================== --- opal/trunk/src/rtp/pcapfile.cxx 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/rtp/pcapfile.cxx 2016-03-15 16:01:05 UTC (rev 34689) @@ -459,7 +459,7 @@ struct { OpalVideoFormat m_format; - PBYTEArray m_context; + OpalVideoFormat::FrameDetectorPtr m_detector; } VideoCodecs[] = { { OPAL_H263 }, { OPAL_H263plus }, @@ -472,9 +472,9 @@ for (PINDEX i = 0; i < PARRAYSIZE(VideoCodecs); ++i) { RTP_DataFrameList::iterator rtp; for (rtp = m_firstFrames.begin(); rtp != m_firstFrames.end(); ++rtp) { - if (VideoCodecs[i].m_format.GetVideoFrameType(rtp->GetPayloadPtr(), - rtp->GetPayloadSize(), - VideoCodecs[i].m_context) == OpalVideoFormat::e_IntraFrame) + if (VideoCodecs[i].m_format.GetFrameType(rtp->GetPayloadPtr(), + rtp->GetPayloadSize(), + VideoCodecs[i].m_detector) == OpalVideoFormat::e_IntraFrame) break; } if (rtp != m_firstFrames.end()) { Modified: opal/trunk/src/win32/opal_lib_2013.vcxproj =================================================================== --- opal/trunk/src/win32/opal_lib_2013.vcxproj 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/win32/opal_lib_2013.vcxproj 2016-03-15 16:01:05 UTC (rev 34689) @@ -403,6 +403,18 @@ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='No Trace|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> </ClCompile> + <ClCompile Include="..\codec\opusmf.cxx" /> + <ClCompile Include="..\codec\opusmf_inc.cxx"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='No Trace|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Android'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='No Trace|Android'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Android'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='No Trace|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + </ClCompile> <ClCompile Include="..\codec\speexmf.cxx" /> <ClCompile Include="..\codec\vp8mf.cxx" /> <ClCompile Include="..\codec\vp8mf_inc.cxx"> Modified: opal/trunk/src/win32/opal_lib_2013.vcxproj.filters =================================================================== --- opal/trunk/src/win32/opal_lib_2013.vcxproj.filters 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/src/win32/opal_lib_2013.vcxproj.filters 2016-03-15 16:01:05 UTC (rev 34689) @@ -750,6 +750,12 @@ <ClCompile Include="..\codec\mpeg4mf_inc.cxx"> <Filter>Source Files\Codec</Filter> </ClCompile> + <ClCompile Include="..\codec\opusmf.cxx"> + <Filter>Source Files\Codec</Filter> + </ClCompile> + <ClCompile Include="..\codec\opusmf_inc.cxx"> + <Filter>Source Files\Codec</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\..\include\codec\echocancel.h"> Modified: opal/trunk/version.h =================================================================== --- opal/trunk/version.h 2016-03-15 11:56:21 UTC (rev 34688) +++ opal/trunk/version.h 2016-03-15 16:01:05 UTC (rev 34689) @@ -37,7 +37,7 @@ #define MAJOR_VERSION 3 #define MINOR_VERSION 17 #define BUILD_TYPE AlphaCode -#define BUILD_NUMBER 1 +#define BUILD_NUMBER 2 #endif // _OPAL_VERSION_H This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-15 11:56:23
|
Revision: 34688 http://sourceforge.net/p/opalvoip/code/34688 Author: rjongbloed Date: 2016-03-15 11:56:21 +0000 (Tue, 15 Mar 2016) Log Message: ----------- Fixed configure with new mechanism for hiding build number Modified Paths: -------------- opal/trunk/configure opal/trunk/make/my_macros.m4 opal/trunk/plugins/configure Modified: opal/trunk/configure =================================================================== --- opal/trunk/configure 2016-03-15 11:53:49 UTC (rev 34687) +++ opal/trunk/configure 2016-03-15 11:56:21 UTC (rev 34688) @@ -6548,7 +6548,7 @@ if ${OPAL_BUILD+:} false; then : build=${OPAL_BUILD} else - build=`cat $VERSION_DIR/version.h | grep BUILD_NUMBER | cut -f3 -d' '` + build=`cat $VERSION_DIR/version.h | grep BUILD_NUMBER | cut -f3 -d' ' | sed 's/0x[1-9]*0*//'` fi if ${OPAL_STAGE+:} false; then : stage=${OPAL_STAGE} Modified: opal/trunk/make/my_macros.m4 =================================================================== --- opal/trunk/make/my_macros.m4 2016-03-15 11:53:49 UTC (rev 34687) +++ opal/trunk/make/my_macros.m4 2016-03-15 11:56:21 UTC (rev 34688) @@ -304,7 +304,7 @@ AC_DEFUN([MY_VERSION_FILE],[ AS_VAR_SET_IF([$2[_MAJOR]],[major=${$2[_MAJOR]}],[major=`cat $1 | grep MAJOR_VERSION | cut -f3 -d' '`]) AS_VAR_SET_IF([$2[_MINOR]],[minor=${$2[_MINOR]}],[minor=`cat $1 | grep MINOR_VERSION | cut -f3 -d' '`]) - AS_VAR_SET_IF([$2[_BUILD]],[build=${$2[_BUILD]}],[build=`cat $1 | grep BUILD_NUMBER | cut -f3 -d' '`]) + AS_VAR_SET_IF([$2[_BUILD]],[build=${$2[_BUILD]}],[build=`cat $1 | grep BUILD_NUMBER | cut -f3 -d' ' | sed 's/0x@<:@1-9@:>@*0*//'`]) AS_VAR_SET_IF([$2[_STAGE]],[stage=${$2[_STAGE]}],[stage=`cat $1 | grep BUILD_TYPE | cut -f 3 -d ' ' | sed 's/BetaCode/-beta/' | sed 's/AlphaCode/-alpha/' | sed 's/ReleaseCode/\./'`]) version="${major}.${minor}.${build}" Modified: opal/trunk/plugins/configure =================================================================== --- opal/trunk/plugins/configure 2016-03-15 11:53:49 UTC (rev 34687) +++ opal/trunk/plugins/configure 2016-03-15 11:56:21 UTC (rev 34688) @@ -6897,7 +6897,7 @@ if ${OPAL_BUILD+:} false; then : build=${OPAL_BUILD} else - build=`cat $VERSION_DIR/version.h | grep BUILD_NUMBER | cut -f3 -d' '` + build=`cat $VERSION_DIR/version.h | grep BUILD_NUMBER | cut -f3 -d' ' | sed 's/0x[1-9]*0*//'` fi if ${OPAL_STAGE+:} false; then : stage=${OPAL_STAGE} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-15 11:53:51
|
Revision: 34687 http://sourceforge.net/p/opalvoip/code/34687 Author: rjongbloed Date: 2016-03-15 11:53:49 +0000 (Tue, 15 Mar 2016) Log Message: ----------- Fixed configure with new mechanism for hiding build number Modified Paths: -------------- ptlib/trunk/configure ptlib/trunk/make/my_macros.m4 Modified: ptlib/trunk/configure =================================================================== --- ptlib/trunk/configure 2016-03-15 11:20:20 UTC (rev 34686) +++ ptlib/trunk/configure 2016-03-15 11:53:49 UTC (rev 34687) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for PTLib 2.17alpha1. +# Generated by GNU Autoconf 2.69 for PTLib 2.17alpha0x10001. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ # Identity of this package. PACKAGE_NAME='PTLib' PACKAGE_TARNAME='ptlib' -PACKAGE_VERSION='2.17alpha1' -PACKAGE_STRING='PTLib 2.17alpha1' +PACKAGE_VERSION='2.17alpha0x10001' +PACKAGE_STRING='PTLib 2.17alpha0x10001' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1608,7 +1608,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures PTLib 2.17alpha1 to adapt to many kinds of systems. +\`configure' configures PTLib 2.17alpha0x10001 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1674,7 +1674,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of PTLib 2.17alpha1:";; + short | recursive ) echo "Configuration of PTLib 2.17alpha0x10001:";; esac cat <<\_ACEOF @@ -1924,7 +1924,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -PTLib configure 2.17alpha1 +PTLib configure 2.17alpha0x10001 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2850,7 +2850,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by PTLib $as_me 2.17alpha1, which was +It was created by PTLib $as_me 2.17alpha0x10001, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -7289,7 +7289,7 @@ if ${PTLIB_BUILD+:} false; then : build=${PTLIB_BUILD} else - build=`cat $VERSION_DIR/version.h | grep BUILD_NUMBER | cut -f3 -d' '` + build=`cat $VERSION_DIR/version.h | grep BUILD_NUMBER | cut -f3 -d' ' | sed 's/0x[1-9]*0*//'` fi if ${PTLIB_STAGE+:} false; then : stage=${PTLIB_STAGE} @@ -20187,7 +20187,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by PTLib $as_me 2.17alpha1, which was +This file was extended by PTLib $as_me 2.17alpha0x10001, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20253,7 +20253,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -PTLib config.status 2.17alpha1 +PTLib config.status 2.17alpha0x10001 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Modified: ptlib/trunk/make/my_macros.m4 =================================================================== --- ptlib/trunk/make/my_macros.m4 2016-03-15 11:20:20 UTC (rev 34686) +++ ptlib/trunk/make/my_macros.m4 2016-03-15 11:53:49 UTC (rev 34687) @@ -304,7 +304,7 @@ AC_DEFUN([MY_VERSION_FILE],[ AS_VAR_SET_IF([$2[_MAJOR]],[major=${$2[_MAJOR]}],[major=`cat $1 | grep MAJOR_VERSION | cut -f3 -d' '`]) AS_VAR_SET_IF([$2[_MINOR]],[minor=${$2[_MINOR]}],[minor=`cat $1 | grep MINOR_VERSION | cut -f3 -d' '`]) - AS_VAR_SET_IF([$2[_BUILD]],[build=${$2[_BUILD]}],[build=`cat $1 | grep BUILD_NUMBER | cut -f3 -d' '`]) + AS_VAR_SET_IF([$2[_BUILD]],[build=${$2[_BUILD]}],[build=`cat $1 | grep BUILD_NUMBER | cut -f3 -d' ' | sed 's/0x@<:@1-9@:>@*0*//'`]) AS_VAR_SET_IF([$2[_STAGE]],[stage=${$2[_STAGE]}],[stage=`cat $1 | grep BUILD_TYPE | cut -f 3 -d ' ' | sed 's/BetaCode/-beta/' | sed 's/AlphaCode/-alpha/' | sed 's/ReleaseCode/\./'`]) version="${major}.${minor}.${build}" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-15 11:20:23
|
Revision: 34686 http://sourceforge.net/p/opalvoip/code/34686 Author: rjongbloed Date: 2016-03-15 11:20:20 +0000 (Tue, 15 Mar 2016) Log Message: ----------- Use of version.h BUILD_NUMBER == UINT_MAX to indicate no build number displayed in version, breaks the PTLIB_CHECK_VERSION() macro. Changed to be masked to 16 bits and hidden if greater 0x10000. Modified Paths: -------------- ptlib/trunk/include/ptlib_config.h.in ptlib/trunk/src/ptlib/common/osutils.cxx Modified: ptlib/trunk/include/ptlib_config.h.in =================================================================== --- ptlib/trunk/include/ptlib_config.h.in 2016-03-15 10:32:05 UTC (rev 34685) +++ ptlib/trunk/include/ptlib_config.h.in 2016-03-15 11:20:20 UTC (rev 34686) @@ -37,7 +37,7 @@ #undef PTLIB_BUILD #undef PTLIB_VERSION -#define PTLIB_VERSION_INT(major,minor,build) ((major<<24)|(minor<<16)|build) +#define PTLIB_VERSION_INT(major,minor,build) ((major<<24)|(minor<<16)|(build&0xffff)) #define PTLIB_CHECK_VERSION(major,minor,build) \ (PTLIB_VERSION_INT(PTLIB_MAJOR,PTLIB_MINOR,PTLIB_BUILD) >= PTLIB_VERSION_INT(major,minor,build)) Modified: ptlib/trunk/src/ptlib/common/osutils.cxx =================================================================== --- ptlib/trunk/src/ptlib/common/osutils.cxx 2016-03-15 10:32:05 UTC (rev 34685) +++ ptlib/trunk/src/ptlib/common/osutils.cxx 2016-03-15 11:20:20 UTC (rev 34686) @@ -2473,11 +2473,11 @@ break; default: - if (m_build != UINT_MAX) + if (m_build < 0x10000) str << '.'; } - if (m_build != UINT_MAX) + if (m_build < 0x10000) str << m_build; if (m_git != NULL && *m_git != '\0') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-15 10:32:07
|
Revision: 34685 http://sourceforge.net/p/opalvoip/code/34685 Author: rjongbloed Date: 2016-03-15 10:32:05 +0000 (Tue, 15 Mar 2016) Log Message: ----------- Fixed spurious errors in log when starting Opus decoding. Modified Paths: -------------- opal/trunk/plugins/audio/Opus/OpusCodec.cpp Modified: opal/trunk/plugins/audio/Opus/OpusCodec.cpp =================================================================== --- opal/trunk/plugins/audio/Opus/OpusCodec.cpp 2016-03-14 10:36:12 UTC (rev 34684) +++ opal/trunk/plugins/audio/Opus/OpusCodec.cpp 2016-03-15 10:32:05 UTC (rev 34685) @@ -308,7 +308,7 @@ for (int frame = 0; frame < frames; ++frame) { if (frame_sizes[frame] > 0) { for (int chan = 0; chan < channels; chan++) { - // Highest "subFrames" bits are VAD, next bit is LDDR flag, repeated for each channel + // Highest "subFrames" bits are VAD, next bit is LBRR flag, repeated for each channel if (frame_data[frame][0] & (0x80 >> ((subFrames+1)*chan + subFrames))) { PTRACE(6, MY_CODEC_LOG, "FEC packet detected"); ++m_countFEC; @@ -499,6 +499,11 @@ } if (m_previousFrame.empty()) { + // Do not start decoding until we get the first + if (packet == NULL) { + toLen = 0; + return true; + } m_previousFrame.resize(samples*m_channels); toLen = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-14 10:36:15
|
Revision: 34684 http://sourceforge.net/p/opalvoip/code/34684 Author: rjongbloed Date: 2016-03-14 10:36:12 +0000 (Mon, 14 Mar 2016) Log Message: ----------- Merged revision(s) 34678-34683 from ptlib/branches/v2_16: Fixed GNU compile Modified Paths: -------------- ptlib/trunk/include/ptclib/script.h Property Changed: ---------------- ptlib/trunk/ Index: ptlib/trunk =================================================================== --- ptlib/trunk 2016-03-14 10:35:14 UTC (rev 34683) +++ ptlib/trunk 2016-03-14 10:36:12 UTC (rev 34684) Property changes on: ptlib/trunk ___________________________________________________________________ Modified: svn:mergeinfo ## -6,7 +6,7 ## /ptlib/branches/v2_10:25177-29189,32921,32947 /ptlib/branches/v2_12:28485-31603 /ptlib/branches/v2_14:31501-33720 -/ptlib/branches/v2_16:34085-34677 +/ptlib/branches/v2_16:34085-34683 /ptlib/branches/v2_2:20746,20791,20827,22014,22942 /ptlib/branches/v2_4:21086,21094,21147,21160,21185,21281,21296,21305,21322,21337,21363,21467,21471-21472,21506,21508,21623,21695,21744,21746,21763,22241,22958,23045-23046,23061,23066,23712 /ptlib/branches/v2_6:22195,22243,22295,22304,22311,22317,22320,22356,22458,22509,22587,22601-22602,22611,22629,22633,22673,22681,22729,22731-22732,22736,22742,22848,22960,22992,23161,23163,23167,23169,23177,23239,23291,23298,23336,23429,23595,23823,23827,23873,24816 \ No newline at end of property Modified: ptlib/trunk/include/ptclib/script.h =================================================================== --- ptlib/trunk/include/ptclib/script.h 2016-03-14 10:35:14 UTC (rev 34683) +++ ptlib/trunk/include/ptclib/script.h 2016-03-14 10:36:12 UTC (rev 34684) @@ -52,7 +52,7 @@ { return PFactory<PScriptLanguage>::CreateInstance(language); } - static PStringList GetLanguages() + static PStringArray GetLanguages() { return PFactory<PScriptLanguage>::GetKeyList(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-14 10:35:16
|
Revision: 34683 http://sourceforge.net/p/opalvoip/code/34683 Author: rjongbloed Date: 2016-03-14 10:35:14 +0000 (Mon, 14 Mar 2016) Log Message: ----------- Fixed GNU compile Modified Paths: -------------- ptlib/branches/v2_16/include/ptclib/script.h Modified: ptlib/branches/v2_16/include/ptclib/script.h =================================================================== --- ptlib/branches/v2_16/include/ptclib/script.h 2016-03-14 09:53:06 UTC (rev 34682) +++ ptlib/branches/v2_16/include/ptclib/script.h 2016-03-14 10:35:14 UTC (rev 34683) @@ -52,7 +52,7 @@ { return PFactory<PScriptLanguage>::CreateInstance(language); } - static PStringList GetLanguages() + static PStringArray GetLanguages() { return PFactory<PScriptLanguage>::GetKeyList(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-14 09:53:09
|
Revision: 34682 http://sourceforge.net/p/opalvoip/code/34682 Author: rjongbloed Date: 2016-03-14 09:53:06 +0000 (Mon, 14 Mar 2016) Log Message: ----------- Merged revision(s) 34679-34681 from opal/branches/v3_16: --------------------- r34681 Try to avoid a race condition in handling REFER with INVITE with replaces clause. --------------------- r34680 Added removal of stale RTP receiver SSRC entries. Bizarre thing with Cisco has many changes of SSRC eventually hitting the maximum SSRC count. Revision Links: -------------- http://sourceforge.net/p/opalvoip/code/34681 http://sourceforge.net/p/opalvoip/code/34680 Modified Paths: -------------- opal/trunk/include/opal/manager.h opal/trunk/include/rtp/rtp_session.h opal/trunk/src/opal/manager.cxx opal/trunk/src/rtp/rtp_session.cxx opal/trunk/src/sip/sipcon.cxx Property Changed: ---------------- opal/trunk/ Index: opal/trunk =================================================================== --- opal/trunk 2016-03-14 09:50:49 UTC (rev 34681) +++ opal/trunk 2016-03-14 09:53:06 UTC (rev 34682) Property changes on: opal/trunk ___________________________________________________________________ Modified: svn:mergeinfo ## -10,7 +10,7 ## /opal/branches/v3_10:25182-29485,30896,32927-32928,32933 /opal/branches/v3_12:28489-31709 /opal/branches/v3_14:31505-33613 -/opal/branches/v3_16:34090-34678 +/opal/branches/v3_16:34090-34681 /opal/branches/v3_2:21143,21220,21227,21253,21455 /opal/branches/v3_4:21060,21062,21088,21092,21111,21113,21115,21119,21143,21148,21151-21152,21155,21158,21184,21188,21253,21265-21266,21283-21284,21298,21300,21303,21307,21309,21311,21327,21331,21333,21359,21367,21369,21488,21556,21564-21565,21568,21570,21620,21625,21631,21748,21751,21756,21759,21761,21767,21770,22246,23044,23140,23143,23286 /opal/branches/v3_6:22169,22178,22184,22186,22197,22204,22216,22251,22253,22255,22258,22260,22291,22296,22300,22306,22308,22313,22319,22336,22353,22358,22436,22447,22449,22497,22511,22517,22519-22521,22527,22536,22538,22589,22596,22599,22617,22620,22622,22630,22640,22655,22675,22682,22726-22728,22730,22733,22738,22745-22746,22800,22820-22821,22842,22844-22845,22851,22853,22889,22896,22902,22904,22906,22918,22924,22928,22946,22965,22967,22976,22978,22980,22982,22994,23028,23123,23125-23126,23128,23157,23165,23173,23175,23183,23294,23341,23465,23467,23474,23521,23829,24346,24809 \ No newline at end of property Modified: opal/trunk/include/opal/manager.h =================================================================== --- opal/trunk/include/opal/manager.h 2016-03-14 09:50:49 UTC (rev 34681) +++ opal/trunk/include/opal/manager.h 2016-03-14 09:53:06 UTC (rev 34682) @@ -1976,6 +1976,16 @@ ) { m_iceTimeout = newInterval; } #endif // OPAL_ICE + /**Get the amount of time before an RTP receive SSRC is stale and removed. + */ + const PTimeInterval & GetStaleReceiverTimeout() const { return m_staleReceiverTimeout; } + + /**Set the amount of time before an RTP receive SSRC is stale and removed. + */ + void SetStaleReceiverTimeout( + const PTimeInterval & newInterval ///< New timeout + ) { m_staleReceiverTimeout = newInterval; } + #if OPAL_SRTP /**Get the amount of time to wait for DTLS handshake. */ @@ -2087,6 +2097,7 @@ #if OPAL_ICE PTimeInterval m_iceTimeout; #endif + PTimeInterval m_staleReceiverTimeout; #if OPAL_SRTP PTimeInterval m_dtlsTimeout; #endif Modified: opal/trunk/include/rtp/rtp_session.h =================================================================== --- opal/trunk/include/rtp/rtp_session.h 2016-03-14 09:50:49 UTC (rev 34681) +++ opal/trunk/include/rtp/rtp_session.h 2016-03-14 09:53:06 UTC (rev 34682) @@ -600,6 +600,7 @@ PString m_toolName; RTPExtensionHeaders m_extensionHeaders; bool m_allowAnySyncSource; + PTimeInterval m_staleReceiverTimeout; PINDEX m_maxOutOfOrderPackets; // Number of packets before we give up waiting for an out of order packet PTimeInterval m_waitOutOfOrderTime; // Milliseconds before we give up on an out of order packet unsigned m_txStatisticsInterval; @@ -661,6 +662,8 @@ virtual void OnRxDelayLastReceiverReport(const RTP_DelayLastReceiverReport & dlrr); virtual SendReceiveStatus SendBYE(); + bool IsStaleReceiver() const; + OpalRTPSession & m_session; Direction m_direction; RTP_SyncSourceId m_sourceIdentifier; Modified: opal/trunk/src/opal/manager.cxx =================================================================== --- opal/trunk/src/opal/manager.cxx 2016-03-14 09:50:49 UTC (rev 34681) +++ opal/trunk/src/opal/manager.cxx 2016-03-14 09:53:06 UTC (rev 34682) @@ -318,6 +318,7 @@ #if OPAL_ICE , m_iceTimeout(0, 15) // Seconds, as per RFC 5245 #endif + , m_staleReceiverTimeout(0,0,1) // Minutes #if OPAL_SRTP , m_dtlsTimeout(0, 3) // Seconds #endif Modified: opal/trunk/src/rtp/rtp_session.cxx =================================================================== --- opal/trunk/src/rtp/rtp_session.cxx 2016-03-14 09:50:49 UTC (rev 34681) +++ opal/trunk/src/rtp/rtp_session.cxx 2016-03-14 09:53:06 UTC (rev 34682) @@ -105,6 +105,7 @@ , m_timeUnits(m_isAudio ? 8 : 90) , m_toolName(PProcess::Current().GetName()) , m_allowAnySyncSource(true) + , m_staleReceiverTimeout(m_manager.GetStaleReceiverTimeout()) , m_maxOutOfOrderPackets(20) , m_waitOutOfOrderTime(GetDefaultOutOfOrderWaitTime(m_isAudio)) , m_txStatisticsInterval(100) @@ -1333,8 +1334,31 @@ } +bool OpalRTPSession::SyncSource::IsStaleReceiver() const +{ + if (m_direction != e_Receiver) + return false; + + // Had n SR sent to us, so still active + if (m_lastSenderReportTime.IsValid() && m_lastSenderReportTime.GetElapsed() < m_session.m_staleReceiverTimeout) + return false; + + // Not started yet, no RR should be sent so safe to leave for now + if (m_packets == 0) + return false; + + // Are still getting packets + if ((PTimer::Tick() - m_lastPacketTick) < m_session.m_staleReceiverTimeout) + return false; + + PTRACE(3, &m_session, *this << "removing stale receiver"); + return true; +} + + void OpalRTPSession::TimedSendReport(PTimer&, P_INT_PTR) { + PTRACE_CONTEXT_ID_PUSH_THREAD(*this); PTRACE(5, *this << "sending periodic report"); SendReport(0, false); } @@ -1347,6 +1371,14 @@ if (!LockReadOnly()) return e_AbortTransport; + // Clean out old stale SSRC's + for (SyncSourceMap::iterator it = m_SSRC.begin(); it != m_SSRC.end();) { + if (it->second->IsStaleReceiver()) + m_SSRC.erase(it++); + else + ++it; + } + if (ssrc != 0) { SyncSource * sender; if (GetSyncSource(ssrc, e_Sender, sender)) { @@ -2484,8 +2516,7 @@ if (m_sendEstablished && IsEstablished()) { m_sendEstablished = false; - m_connection.GetEndPoint().GetManager().QueueDecoupledEvent( - new PSafeWorkNoArg<OpalConnection, bool>(&m_connection, &OpalConnection::InternalOnEstablished)); + m_manager.QueueDecoupledEvent(new PSafeWorkNoArg<OpalConnection, bool>(&m_connection, &OpalConnection::InternalOnEstablished)); } // Check for single port operation, incoming RTCP on RTP @@ -2612,8 +2643,7 @@ get one failed without the other, we don't bother. */ if (subchannel == e_Data && m_connection.OnMediaFailed(m_sessionId)) { PTRACE(3, *this << "aborting transport, queuing close of media session."); - m_connection.GetEndPoint().GetManager().QueueDecoupledEvent( - new PSafeWorkNoArg<OpalRTPSession, bool>(this, &OpalRTPSession::Close)); + m_manager.QueueDecoupledEvent(new PSafeWorkNoArg<OpalRTPSession, bool>(this, &OpalRTPSession::Close)); } } Modified: opal/trunk/src/sip/sipcon.cxx =================================================================== --- opal/trunk/src/sip/sipcon.cxx 2016-03-14 09:50:49 UTC (rev 34681) +++ opal/trunk/src/sip/sipcon.cxx 2016-03-14 09:53:06 UTC (rev 34682) @@ -338,6 +338,18 @@ UnlockReadWrite(); + // If forwardParty is a connection token, then must be INVITE with replaces scenario + if (!m_forwardParty.IsEmpty()) { + PSafePtr<SIPConnection> replacerConnection = GetEndPoint().GetSIPConnectionWithLock(m_forwardParty); + if (replacerConnection != NULL) { + PTRACE(3, "INVITE with replace on " << *replacerConnection); + + /* According to RFC 3891 we now send a 200 OK in both the early and confirmed + dialog cases. */ + replacerConnection->InternalSetConnected(true); + } + } + SIPDialogNotification::Events notifyDialogEvent = SIPDialogNotification::NoEvent; SIP_PDU::StatusCodes sipCode = SIP_PDU::IllegalStatusCode; @@ -449,19 +461,6 @@ // Close media and indicate call ended, even though we have a little bit more // to go in clean up, don't let other bits wait for it. OpalRTPConnection::OnReleased(); - - // If forwardParty is a connection token, then must be INVITE with replaces scenario - if (!m_forwardParty.IsEmpty()) { - PSafePtr<SIPConnection> replacerConnection = GetEndPoint().GetSIPConnectionWithLock(m_forwardParty); - if (replacerConnection != NULL) { - PTRACE(3, "INVITE with replace on " << *replacerConnection); - - /* According to RFC 3891 we now send a 200 OK in both the early and confirmed - dialog cases. OnReleased() is responsible for if the replaced connection is - sent a BYE or a CANCEL. */ - replacerConnection->InternalSetConnected(true); - } - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-14 09:50:52
|
Revision: 34681 http://sourceforge.net/p/opalvoip/code/34681 Author: rjongbloed Date: 2016-03-14 09:50:49 +0000 (Mon, 14 Mar 2016) Log Message: ----------- Try to avoid a race condition in handling REFER with INVITE with replaces clause. Modified Paths: -------------- opal/branches/v3_16/src/sip/sipcon.cxx Modified: opal/branches/v3_16/src/sip/sipcon.cxx =================================================================== --- opal/branches/v3_16/src/sip/sipcon.cxx 2016-03-14 09:47:03 UTC (rev 34680) +++ opal/branches/v3_16/src/sip/sipcon.cxx 2016-03-14 09:50:49 UTC (rev 34681) @@ -338,6 +338,18 @@ UnlockReadWrite(); + // If forwardParty is a connection token, then must be INVITE with replaces scenario + if (!m_forwardParty.IsEmpty()) { + PSafePtr<SIPConnection> replacerConnection = GetEndPoint().GetSIPConnectionWithLock(m_forwardParty); + if (replacerConnection != NULL) { + PTRACE(3, "INVITE with replace on " << *replacerConnection); + + /* According to RFC 3891 we now send a 200 OK in both the early and confirmed + dialog cases. */ + replacerConnection->InternalSetConnected(true); + } + } + SIPDialogNotification::Events notifyDialogEvent = SIPDialogNotification::NoEvent; SIP_PDU::StatusCodes sipCode = SIP_PDU::IllegalStatusCode; @@ -449,19 +461,6 @@ // Close media and indicate call ended, even though we have a little bit more // to go in clean up, don't let other bits wait for it. OpalRTPConnection::OnReleased(); - - // If forwardParty is a connection token, then must be INVITE with replaces scenario - if (!m_forwardParty.IsEmpty()) { - PSafePtr<SIPConnection> replacerConnection = GetEndPoint().GetSIPConnectionWithLock(m_forwardParty); - if (replacerConnection != NULL) { - PTRACE(3, "INVITE with replace on " << *replacerConnection); - - /* According to RFC 3891 we now send a 200 OK in both the early and confirmed - dialog cases. OnReleased() is responsible for if the replaced connection is - sent a BYE or a CANCEL. */ - replacerConnection->InternalSetConnected(true); - } - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-14 09:47:05
|
Revision: 34680 http://sourceforge.net/p/opalvoip/code/34680 Author: rjongbloed Date: 2016-03-14 09:47:03 +0000 (Mon, 14 Mar 2016) Log Message: ----------- Added removal of stale RTP receiver SSRC entries. Bizarre thing with Cisco has many changes of SSRC eventually hitting the maximum SSRC count. Modified Paths: -------------- opal/branches/v3_16/include/opal/manager.h opal/branches/v3_16/include/rtp/rtp_session.h opal/branches/v3_16/src/opal/manager.cxx opal/branches/v3_16/src/rtp/rtp_session.cxx Modified: opal/branches/v3_16/include/opal/manager.h =================================================================== --- opal/branches/v3_16/include/opal/manager.h 2016-03-12 17:56:10 UTC (rev 34679) +++ opal/branches/v3_16/include/opal/manager.h 2016-03-14 09:47:03 UTC (rev 34680) @@ -1976,6 +1976,16 @@ ) { m_iceTimeout = newInterval; } #endif // OPAL_ICE + /**Get the amount of time before an RTP receive SSRC is stale and removed. + */ + const PTimeInterval & GetStaleReceiverTimeout() const { return m_staleReceiverTimeout; } + + /**Set the amount of time before an RTP receive SSRC is stale and removed. + */ + void SetStaleReceiverTimeout( + const PTimeInterval & newInterval ///< New timeout + ) { m_staleReceiverTimeout = newInterval; } + #if OPAL_SRTP /**Get the amount of time to wait for DTLS handshake. */ @@ -2087,6 +2097,7 @@ #if OPAL_ICE PTimeInterval m_iceTimeout; #endif + PTimeInterval m_staleReceiverTimeout; #if OPAL_SRTP PTimeInterval m_dtlsTimeout; #endif Modified: opal/branches/v3_16/include/rtp/rtp_session.h =================================================================== --- opal/branches/v3_16/include/rtp/rtp_session.h 2016-03-12 17:56:10 UTC (rev 34679) +++ opal/branches/v3_16/include/rtp/rtp_session.h 2016-03-14 09:47:03 UTC (rev 34680) @@ -600,6 +600,7 @@ PString m_toolName; RTPExtensionHeaders m_extensionHeaders; bool m_allowAnySyncSource; + PTimeInterval m_staleReceiverTimeout; PINDEX m_maxOutOfOrderPackets; // Number of packets before we give up waiting for an out of order packet PTimeInterval m_waitOutOfOrderTime; // Milliseconds before we give up on an out of order packet unsigned m_txStatisticsInterval; @@ -661,6 +662,8 @@ virtual void OnRxDelayLastReceiverReport(const RTP_DelayLastReceiverReport & dlrr); virtual SendReceiveStatus SendBYE(); + bool IsStaleReceiver() const; + OpalRTPSession & m_session; Direction m_direction; RTP_SyncSourceId m_sourceIdentifier; Modified: opal/branches/v3_16/src/opal/manager.cxx =================================================================== --- opal/branches/v3_16/src/opal/manager.cxx 2016-03-12 17:56:10 UTC (rev 34679) +++ opal/branches/v3_16/src/opal/manager.cxx 2016-03-14 09:47:03 UTC (rev 34680) @@ -321,6 +321,7 @@ #if OPAL_ICE , m_iceTimeout(0, 5) // Seconds #endif + , m_staleReceiverTimeout(0,0,1) // Minutes #if OPAL_SRTP , m_dtlsTimeout(0, 3) // Seconds #endif Modified: opal/branches/v3_16/src/rtp/rtp_session.cxx =================================================================== --- opal/branches/v3_16/src/rtp/rtp_session.cxx 2016-03-12 17:56:10 UTC (rev 34679) +++ opal/branches/v3_16/src/rtp/rtp_session.cxx 2016-03-14 09:47:03 UTC (rev 34680) @@ -105,6 +105,7 @@ , m_timeUnits(m_isAudio ? 8 : 90) , m_toolName(PProcess::Current().GetName()) , m_allowAnySyncSource(true) + , m_staleReceiverTimeout(m_manager.GetStaleReceiverTimeout()) , m_maxOutOfOrderPackets(20) , m_waitOutOfOrderTime(GetDefaultOutOfOrderWaitTime(m_isAudio)) , m_txStatisticsInterval(100) @@ -1320,8 +1321,31 @@ } +bool OpalRTPSession::SyncSource::IsStaleReceiver() const +{ + if (m_direction != e_Receiver) + return false; + + // Had n SR sent to us, so still active + if (m_lastSenderReportTime.IsValid() && m_lastSenderReportTime.GetElapsed() < m_session.m_staleReceiverTimeout) + return false; + + // Not started yet, no RR should be sent so safe to leave for now + if (m_packets == 0) + return false; + + // Are still getting packets + if ((PTimer::Tick() - m_lastPacketTick) < m_session.m_staleReceiverTimeout) + return false; + + PTRACE(3, &m_session, *this << "removing stale receiver"); + return true; +} + + void OpalRTPSession::TimedSendReport(PTimer&, P_INT_PTR) { + PTRACE_CONTEXT_ID_PUSH_THREAD(*this); PTRACE(5, *this << "sending periodic report"); SendReport(0, false); } @@ -1334,6 +1358,14 @@ if (!LockReadOnly()) return e_AbortTransport; + // Clean out old stale SSRC's + for (SyncSourceMap::iterator it = m_SSRC.begin(); it != m_SSRC.end();) { + if (it->second->IsStaleReceiver()) + m_SSRC.erase(it++); + else + ++it; + } + if (ssrc != 0) { SyncSource * sender; if (GetSyncSource(ssrc, e_Sender, sender)) { @@ -2459,8 +2491,7 @@ if (m_sendEstablished && IsEstablished()) { m_sendEstablished = false; - m_connection.GetEndPoint().GetManager().QueueDecoupledEvent( - new PSafeWorkNoArg<OpalConnection, bool>(&m_connection, &OpalConnection::InternalOnEstablished)); + m_manager.QueueDecoupledEvent(new PSafeWorkNoArg<OpalConnection, bool>(&m_connection, &OpalConnection::InternalOnEstablished)); } // Check for single port operation, incoming RTCP on RTP @@ -2587,8 +2618,7 @@ get one failed without the other, we don't bother. */ if (subchannel == e_Data && m_connection.OnMediaFailed(m_sessionId)) { PTRACE(3, *this << "aborting transport, queuing close of media session."); - m_connection.GetEndPoint().GetManager().QueueDecoupledEvent( - new PSafeWorkNoArg<OpalRTPSession, bool>(this, &OpalRTPSession::Close)); + m_manager.QueueDecoupledEvent(new PSafeWorkNoArg<OpalRTPSession, bool>(this, &OpalRTPSession::Close)); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-12 17:56:13
|
Revision: 34679 http://sourceforge.net/p/opalvoip/code/34679 Author: rjongbloed Date: 2016-03-12 17:56:10 +0000 (Sat, 12 Mar 2016) Log Message: ----------- Merged revision(s) 34625-34678 from opal/branches/v3_16: --------------------- r34677 Changed SIP authentication so that if INVITE to domain which was not registered, but we are asked for authentication, we use the credentials of the first registration current. While not guaranteed to work, it will under some odd circumstances (e.g. redirect which uses different address for same registrar/proxy) and will not cause any damage if it subsequently doesn't work. --------------------- r34644 Fixed PScriptLanguage::CreateCall() and various other minor bugs in scripting code. Also added functions to get the current language name for the PScriptLanguage instance. Revision Links: -------------- http://sourceforge.net/p/opalvoip/code/34677 http://sourceforge.net/p/opalvoip/code/34644 Modified Paths: -------------- opal/trunk/include/sip/handlers.h opal/trunk/samples/server/main.cxx opal/trunk/src/sip/handlers.cxx opal/trunk/src/sip/sipep.cxx Property Changed: ---------------- opal/trunk/ Index: opal/trunk =================================================================== --- opal/trunk 2016-03-12 17:54:04 UTC (rev 34678) +++ opal/trunk 2016-03-12 17:56:10 UTC (rev 34679) Property changes on: opal/trunk ___________________________________________________________________ Modified: svn:mergeinfo ## -10,7 +10,7 ## /opal/branches/v3_10:25182-29485,30896,32927-32928,32933 /opal/branches/v3_12:28489-31709 /opal/branches/v3_14:31505-33613 -/opal/branches/v3_16:34090-34624 +/opal/branches/v3_16:34090-34678 /opal/branches/v3_2:21143,21220,21227,21253,21455 /opal/branches/v3_4:21060,21062,21088,21092,21111,21113,21115,21119,21143,21148,21151-21152,21155,21158,21184,21188,21253,21265-21266,21283-21284,21298,21300,21303,21307,21309,21311,21327,21331,21333,21359,21367,21369,21488,21556,21564-21565,21568,21570,21620,21625,21631,21748,21751,21756,21759,21761,21767,21770,22246,23044,23140,23143,23286 /opal/branches/v3_6:22169,22178,22184,22186,22197,22204,22216,22251,22253,22255,22258,22260,22291,22296,22300,22306,22308,22313,22319,22336,22353,22358,22436,22447,22449,22497,22511,22517,22519-22521,22527,22536,22538,22589,22596,22599,22617,22620,22622,22630,22640,22655,22675,22682,22726-22728,22730,22733,22738,22745-22746,22800,22820-22821,22842,22844-22845,22851,22853,22889,22896,22902,22904,22906,22918,22924,22928,22946,22965,22967,22976,22978,22980,22982,22994,23028,23123,23125-23126,23128,23157,23165,23173,23175,23183,23294,23341,23465,23467,23474,23521,23829,24346,24809 \ No newline at end of property Modified: opal/trunk/include/sip/handlers.h =================================================================== --- opal/trunk/include/sip/handlers.h 2016-03-12 17:54:04 UTC (rev 34678) +++ opal/trunk/include/sip/handlers.h 2016-03-12 17:56:10 UTC (rev 34679) @@ -360,12 +360,6 @@ bool DeleteObjectsToBeRemoved() { return m_handlersList.DeleteObjectsToBeRemoved(); } - /** Get the first handler in the list. Further enumeration may be done by - the ++operator on the safe pointer. - */ - PSafePtr<SIPHandler> GetFirstHandler(PSafetyMode mode = PSafeReference) const - { return PSafePtr<SIPHandler>(m_handlersList, mode); } - /** * Return the number of registered accounts */ @@ -376,6 +370,17 @@ */ PStringList GetAddresses(bool includeOffline, SIP_PDU::Methods meth, const PString & eventPackage = PString::Empty()) const; + /** Get the first handler in the list. Further enumeration may be done by + the ++operator on the safe pointer. + */ + PSafePtr<SIPHandler> GetFirstHandler(PSafetyMode mode = PSafeReference) const + { return PSafePtr<SIPHandler>(m_handlersList, mode); } + + /** Get the first handler in the list for the specified method. Further enumeration may be done by + the ++operator on the safe pointer. + */ + PSafePtr<SIPHandler> FindFirstHandler(SIP_PDU::Methods meth, PSafetyMode mode = PSafeReference) const; + /** * Find the SIPHandler object with the specified callID */ Modified: opal/trunk/samples/server/main.cxx =================================================================== --- opal/trunk/samples/server/main.cxx 2016-03-12 17:54:04 UTC (rev 34678) +++ opal/trunk/samples/server/main.cxx 2016-03-12 17:56:10 UTC (rev 34679) @@ -690,11 +690,8 @@ #endif #if OPAL_SCRIPT - PFactory<PScriptLanguage>::KeyList_T keys = PFactory<PScriptLanguage>::GetKeyList(); - if (!keys.empty()) { - PStringArray languages; - for (PFactory<PScriptLanguage>::KeyList_T::iterator it = keys.begin(); it != keys.end(); ++it) - languages.AppendString(*it); + PStringArray languages = PScriptLanguage::GetLanguages(); + if (!languages.empty()) { PCaselessString language = cfg.GetString(ScriptLanguageKey, languages[0]); rsrc->Add(new PHTTPRadioField(ScriptLanguageKey, languages, languages.GetValuesIndex(language),"Interpreter script language.")); Modified: opal/trunk/src/sip/handlers.cxx =================================================================== --- opal/trunk/src/sip/handlers.cxx 2016-03-12 17:54:04 UTC (rev 34678) +++ opal/trunk/src/sip/handlers.cxx 2016-03-12 17:56:10 UTC (rev 34679) @@ -2566,6 +2566,16 @@ } +PSafePtr<SIPHandler> SIPHandlersList::FindFirstHandler(SIP_PDU::Methods meth, PSafetyMode mode) const +{ + PSafePtr<SIPHandler> handler(m_handlersList, PSafeReference); + while (handler != NULL && handler->GetMethod() != meth) + ++handler; + handler.SetSafetyMode(mode); + return handler; +} + + PSafePtr<SIPHandler> SIPHandlersList::FindSIPHandlerByCallID(const PString & callID, PSafetyMode mode) { return PSafePtrCast<SIPHandlerBase, SIPHandler>(m_handlersList.FindWithLock(callID, mode)); Modified: opal/trunk/src/sip/sipep.cxx =================================================================== --- opal/trunk/src/sip/sipep.cxx 2016-03-12 17:54:04 UTC (rev 34678) +++ opal/trunk/src/sip/sipep.cxx 2016-03-12 17:56:10 UTC (rev 34679) @@ -2087,8 +2087,11 @@ if (m_registeredUserMode) return false; - if ((handler = activeSIPHandlers.FindSIPHandlerByAuthRealm(realm, PSafeReadOnly)) == NULL) - return false; + if ((handler = activeSIPHandlers.FindSIPHandlerByAuthRealm(realm, PSafeReadOnly)) == NULL) { + if ((handler = activeSIPHandlers.FindFirstHandler(SIP_PDU::Method_REGISTER, PSafeReadOnly)) == NULL) + return false; + PTRACE(4, "Using first registrar " << handler->GetAddressOfRecord() << " for authentication"); + } } // really just after password, but username MAY change too. @@ -2177,9 +2180,7 @@ } else if (domain.IsEmpty() || OpalIsE164(domain)) { // No context, just get first registration - handler = activeSIPHandlers.GetFirstHandler(); - while (handler != NULL && handler->GetMethod() != SIP_PDU::Method_REGISTER) - ++handler; + handler = activeSIPHandlers.FindFirstHandler(SIP_PDU::Method_REGISTER); if (handler != NULL) { PTRACE(4, "Using first registrar " << handler->GetAddressOfRecord() << " for tel URI"); if (connection != NULL) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-12 17:54:06
|
Revision: 34678 http://sourceforge.net/p/opalvoip/code/34678 Author: rjongbloed Date: 2016-03-12 17:54:04 +0000 (Sat, 12 Mar 2016) Log Message: ----------- Merged revision(s) 34624-34677 from ptlib/branches/v2_16: --------------------- r34665 Fixed PAESContext for decryption mode. --------------------- r34645 Added scripting language, if available, to VXML. --------------------- r34644 Fixed PScriptLanguage::CreateCall() and various other minor bugs in scripting code. Also added functions to get the current language name for the PScriptLanguage instance. --------------------- r34640 Disable all XML entity expansion, unless re-enabled via PCML::Option, to finally protect against "billion laughs" attack. The previous mothod did not protect against expansion within element attributes, only in data. Revision Links: -------------- http://sourceforge.net/p/opalvoip/code/34665 http://sourceforge.net/p/opalvoip/code/34645 http://sourceforge.net/p/opalvoip/code/34644 http://sourceforge.net/p/opalvoip/code/34640 Modified Paths: -------------- ptlib/trunk/include/ptclib/jscript.h ptlib/trunk/include/ptclib/lua.h ptlib/trunk/include/ptclib/pxml.h ptlib/trunk/include/ptclib/script.h ptlib/trunk/include/ptclib/vxml.h ptlib/trunk/src/ptclib/jscript.cxx ptlib/trunk/src/ptclib/lua.cxx ptlib/trunk/src/ptclib/pssl.cxx ptlib/trunk/src/ptclib/pxml.cxx ptlib/trunk/src/ptclib/script.cxx ptlib/trunk/src/ptclib/vxml.cxx Property Changed: ---------------- ptlib/trunk/ Index: ptlib/trunk =================================================================== --- ptlib/trunk 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk 2016-03-12 17:54:04 UTC (rev 34678) Property changes on: ptlib/trunk ___________________________________________________________________ Modified: svn:mergeinfo ## -6,7 +6,7 ## /ptlib/branches/v2_10:25177-29189,32921,32947 /ptlib/branches/v2_12:28485-31603 /ptlib/branches/v2_14:31501-33720 -/ptlib/branches/v2_16:34085-34623 +/ptlib/branches/v2_16:34085-34677 /ptlib/branches/v2_2:20746,20791,20827,22014,22942 /ptlib/branches/v2_4:21086,21094,21147,21160,21185,21281,21296,21305,21322,21337,21363,21467,21471-21472,21506,21508,21623,21695,21744,21746,21763,22241,22958,23045-23046,23061,23066,23712 /ptlib/branches/v2_6:22195,22243,22295,22304,22311,22317,22320,22356,22458,22509,22587,22601-22602,22611,22629,22633,22673,22681,22729,22731-22732,22736,22742,22848,22960,22992,23161,23163,23167,23169,23177,23239,23291,23298,23336,23429,23595,23823,23827,23873,24816 \ No newline at end of property Modified: ptlib/trunk/include/ptclib/jscript.h =================================================================== --- ptlib/trunk/include/ptclib/jscript.h 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/include/ptclib/jscript.h 2016-03-12 17:54:04 UTC (rev 34678) @@ -62,8 +62,14 @@ ~PJavaScript(); //@} - /**@name Path addition functions */ + /**@name Scripting functions */ //@{ + /// Get the name of this scripting language + static PString LanguageName(); + + /// Get the name of this scripting language + virtual PString GetLanguageName() const; + /**Load a JavaScript script from a file. */ virtual bool LoadFile( Modified: ptlib/trunk/include/ptclib/lua.h =================================================================== --- ptlib/trunk/include/ptclib/lua.h 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/include/ptclib/lua.h 2016-03-12 17:54:04 UTC (rev 34678) @@ -71,8 +71,14 @@ ~PLua(); //@} - /**@name Path addition functions */ + /**@name Scripting functions */ //@{ + /// Get the name of this scripting language + static PString LanguageName(); + + /// Get the name of this scripting language + virtual PString GetLanguageName() const; + /**Load a Lua script from a file. */ virtual bool LoadFile( Modified: ptlib/trunk/include/ptclib/pxml.h =================================================================== --- ptlib/trunk/include/ptclib/pxml.h 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/include/ptclib/pxml.h 2016-03-12 17:54:04 UTC (rev 34678) @@ -54,12 +54,12 @@ PCLASSINFO(PXMLBase, PObject); public: enum { - DEFAULT_MAX_ENTITY_LENGTH = 4096 + DEFAULT_MAX_ENTITY_LENGTH = 65536 }; P_DECLARE_BITWISE_ENUM_EX( Options, - 7, + 8, ( NoOptions, Indent, @@ -68,9 +68,10 @@ NoIgnoreWhiteSpace, CloseExtended, WithNS, - FragmentOnly + FragmentOnly, + ExpandEntities ), - AllOptions = (1<<(6+1))-1 + AllOptions = (1<<8)-1 ); enum StandAloneType { @@ -499,7 +500,7 @@ class PXMLParserBase { protected: - PXMLParserBase(bool withNS); + PXMLParserBase(PXMLBase::Options options); public: ~PXMLParserBase(); @@ -515,6 +516,14 @@ virtual void StartElement(const char * name, const char **attrs) = 0; virtual void EndElement(const char * name) = 0; virtual void AddCharacterData(const char * data, int len) = 0; + virtual void Entity(const char *entityName, + int is_parameter_entity, + const char *value, + int value_length, + const char *base, + const char *systemId, + const char *publicId, + const char *notationName); virtual bool Progress() { return true; } @@ -530,6 +539,7 @@ off_t m_consumed; unsigned m_percent; bool m_userAborted; + bool m_expandEntities; }; Modified: ptlib/trunk/include/ptclib/script.h =================================================================== --- ptlib/trunk/include/ptclib/script.h 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/include/ptclib/script.h 2016-03-12 17:54:04 UTC (rev 34678) @@ -48,7 +48,14 @@ { PCLASSINFO(PScriptLanguage, PObject) public: - static PScriptLanguage * Create(const PString & language); + static PScriptLanguage * Create(const PString & language) + { + return PFactory<PScriptLanguage>::CreateInstance(language); + } + static PStringList GetLanguages() + { + return PFactory<PScriptLanguage>::GetKeyList(); + } /**@name Construction */ //@{ @@ -60,8 +67,11 @@ ~PScriptLanguage(); //@} - /**@name Path addition functions */ + /**@name Scripting functions */ //@{ + /// Get the name of this scripting language + virtual PString GetLanguageName() const = 0; + /**Load a script from a file. */ virtual bool LoadFile( Modified: ptlib/trunk/include/ptclib/vxml.h =================================================================== --- ptlib/trunk/include/ptclib/vxml.h 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/include/ptclib/vxml.h 2016-03-12 17:54:04 UTC (rev 34678) @@ -44,6 +44,7 @@ #include <ptclib/pwavfile.h> #include <ptclib/ptts.h> #include <ptclib/url.h> +#include <ptclib/script.h> #include <queue> @@ -329,6 +330,9 @@ PStringToString m_variables; PString m_variableScope; +#if P_SCRIPTS + PScriptLanguage *m_scriptContext; +#endif std::queue<char> m_userInputQueue; PDECLARE_MUTEX(m_userInputMutex); Modified: ptlib/trunk/src/ptclib/jscript.cxx =================================================================== --- ptlib/trunk/src/ptclib/jscript.cxx 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/src/ptclib/jscript.cxx 2016-03-12 17:54:04 UTC (rev 34678) @@ -75,7 +75,8 @@ #define PTraceModule() "JavaScript" -PFACTORY_CREATE(PFactory<PScriptLanguage>, PJavaScript, "Java", false); +static PConstString const JavaName("Java"); +PFACTORY_CREATE(PFactory<PScriptLanguage>, PJavaScript, JavaName, false); static atomic<bool> V8_initialised; @@ -250,16 +251,16 @@ } - void SetMember(v8::Handle<v8::Object> object, const PString & name, v8::Handle<v8::Value> value) + bool SetMember(v8::Handle<v8::Object> object, const PString & name, v8::Handle<v8::Value> value) { if (m_isolate == NULL) - return; + return false; // set flags if array access if (name[0] == '[') - object->Set(name.Mid(1).AsInteger(), value); + return object->Set(name.Mid(1).AsInteger(), value); else - object->Set(NewString(name), value); + return object->Set(NewString(name), value); } @@ -346,6 +347,12 @@ } + bool NewObject(const PString & name) + { + return false; + } + + bool SetVar(const PString & key, const PVarType & var) { if (m_isolate == NULL) @@ -358,40 +365,34 @@ PStringArray tokens; if (ParseKey(key, tokens) < 1) { - PTRACE(5, "SetVar '" << key << " is too short"); + PTRACE(3, "SetVar \"" << key << "\" is too short"); return false; } v8::Handle<v8::Object> object = context->Global(); - int i = 0; - - while (i > 0) { - + PINDEX i; + for (i = 0; i < tokens.GetSize()-1; ++i) { // get the member variable v8::Handle<v8::Value> value = GetMember(object, tokens[i]); if (value.IsEmpty()) { - PTRACE(5, "Cannot get element '" << tokens[i] << "'"); + PTRACE(3, "Cannot get element \"" << tokens[i] << '"'); return false; } + // if path has ended, return error + object = value->ToObject(); + if (object.IsEmpty()) { + PTRACE(3, "SetVar intermediate element \"" << tokens[i] << "\" not found"); + return false; + } + // terminals must not be composites, internal nodes must be composites bool isObject = value->IsObject(); if (!isObject) { - tokens.SetSize(i + 1); - PTRACE(5, "GetVar intermediate node '" << setfill('.') << tokens << "' is not a composite"); + PTRACE(3, "SetVar intermediate element \"" << tokens[i] << "\" is not a composite"); return false; } - - // if path has ended, return error - object = value->ToObject(); - if (object->IsNull()) { - tokens.SetSize(i + 1); - PTRACE(5, "GetVar intermediate node '" << setfill('.') << tokens << " not found"); - return false; - } - - i++; } v8::Handle<v8::Value> value; @@ -439,11 +440,11 @@ case PVarType::VarStaticBinary: case PVarType::VarDynamicBinary: default: + value = v8::Object::New(m_isolate); break; } - SetMember(object, tokens[i], value); - return true; + return SetMember(object, tokens[i], value); } @@ -502,6 +503,18 @@ } +PString PJavaScript::LanguageName() +{ + return JavaName; +} + + +PString PJavaScript::GetLanguageName() const +{ + return JavaName; +} + + bool PJavaScript::LoadFile(const PFilePath & /*filename*/) { return false; @@ -520,9 +533,11 @@ } -bool PJavaScript::CreateComposite(const PString & /*name*/) +bool PJavaScript::CreateComposite(const PString & name) { - return false; + PVarType dummy; + dummy.SetType(PVarType::VarStaticBinary); + return m_private->SetVar(name, dummy); } Modified: ptlib/trunk/src/ptclib/lua.cxx =================================================================== --- ptlib/trunk/src/ptclib/lua.cxx 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/src/ptclib/lua.cxx 2016-03-12 17:54:04 UTC (rev 34678) @@ -56,7 +56,8 @@ #define PTraceModule() "Lua" -PFACTORY_CREATE(PFactory<PScriptLanguage>, PLua, "Lua", false); +static PConstString const LuaName("Lua"); +PFACTORY_CREATE(PFactory<PScriptLanguage>, PLua, LuaName, false); #define new PNEW @@ -109,6 +110,18 @@ } +PString PLua::LanguageName() +{ + return LuaName; +} + + +PString PLua::GetLanguageName() const +{ + return LuaName; +} + + bool PLua::LoadFile(const PFilePath & filename) { PWaitAndSignal mutex(m_mutex); @@ -612,7 +625,7 @@ if (luaError.IsEmpty()) OnError(code, psprintf("Error code %i", code)); else - OnError(code, str); + OnError(code, luaError); } if (pop > 0) Modified: ptlib/trunk/src/ptclib/pssl.cxx =================================================================== --- ptlib/trunk/src/ptclib/pssl.cxx 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/src/ptclib/pssl.cxx 2016-03-12 17:54:04 UTC (rev 34678) @@ -986,7 +986,7 @@ if (encrypt) SetEncrypt(data, numBits); else - SetEncrypt(data, numBits); + SetDecrypt(data, numBits); } Modified: ptlib/trunk/src/ptclib/pxml.cxx =================================================================== --- ptlib/trunk/src/ptclib/pxml.cxx 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/src/ptclib/pxml.cxx 2016-03-12 17:54:04 UTC (rev 34678) @@ -122,14 +122,29 @@ } -PXMLParserBase::PXMLParserBase(bool withNS) +static void PXML_EntityDeclHandler(void *userData, + const XML_Char *entityName, + int is_parameter_entity, + const XML_Char *value, + int value_length, + const XML_Char *base, + const XML_Char *systemId, + const XML_Char *publicId, + const XML_Char *notationName) +{ + ((PXMLParserBase *)userData)->Entity(entityName, is_parameter_entity, value, value_length, base, systemId, publicId, notationName); +} + + +PXMLParserBase::PXMLParserBase(PXMLBase::Options options) : m_parsing(true) , m_total(0) , m_consumed(0) , m_percent(0) , m_userAborted(false) + , m_expandEntities(options & PXMLBase::ExpandEntities) { - if (withNS) + if (options & PXMLBase::WithNS) m_context = XML_ParserCreateNS(NULL, '|'); else m_context = XML_ParserCreate(NULL); @@ -141,6 +156,7 @@ XML_SetXmlDeclHandler (MY_CONTEXT, PXML_XmlDeclHandler); XML_SetDoctypeDeclHandler (MY_CONTEXT, PXML_StartDocTypeDecl, PXML_EndDocTypeDecl); XML_SetNamespaceDeclHandler(MY_CONTEXT, PXML_StartNamespaceDeclHandler, PXML_EndNamespaceDeclHandler); + XML_SetEntityDeclHandler (MY_CONTEXT, PXML_EntityDeclHandler); } @@ -238,7 +254,7 @@ PXMLParser::PXMLParser(PXML & doc, Options options, off_t progressTotal) : PXMLBase(options) - , PXMLParserBase(options & WithNS) + , PXMLParserBase(options) , m_document(doc) , m_currentElement(NULL) , m_lastData(NULL) @@ -335,7 +351,7 @@ unsigned checkLen = len + ((m_lastData != NULL) ? m_lastData->GetString().GetLength() : 0); if (checkLen >= m_maxEntityLength) { PTRACE(2, "PXML\tAborting XML parse at size " << m_maxEntityLength << " - possible 'billion laugh' attack"); - XML_StopParser((XML_Parser)m_context, XML_FALSE); + XML_StopParser(MY_CONTEXT, XML_FALSE); return; } @@ -365,6 +381,24 @@ } +void PXMLParserBase::Entity(const char * /*entityName*/, + int /*is_parameter_entity*/, + const char * /*value*/, + int /*value_length*/, + const char * /*base*/, + const char * /*systemId*/, + const char * /*publicId*/, + const char * /*notationName*/) +{ + if (m_expandEntities) + return; + + // Disable entity expansion completely to prevent billion laughs attack + PTRACE(2, "PXML\tAborting XML parse at when expanding entity - possible 'billion laughs' attack"); + XML_StopParser(MY_CONTEXT, XML_FALSE); +} + + /////////////////////////////////////////////////////////////////////////////////////////////// PXML::PXML(Options options, const char * noIndentElementsParam) Modified: ptlib/trunk/src/ptclib/script.cxx =================================================================== --- ptlib/trunk/src/ptclib/script.cxx 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/src/ptclib/script.cxx 2016-03-12 17:54:04 UTC (rev 34678) @@ -74,7 +74,7 @@ m_lastErrorText = str; m_mutex.Signal(); - PTRACE(2, GetClass(), "Error " << code << ": " << str); + PTRACE(2, GetLanguageName(), "Error " << code << ": " << str); } Modified: ptlib/trunk/src/ptclib/vxml.cxx =================================================================== --- ptlib/trunk/src/ptclib/vxml.cxx 2016-03-12 16:30:53 UTC (rev 34677) +++ ptlib/trunk/src/ptclib/vxml.cxx 2016-03-12 17:54:04 UTC (rev 34678) @@ -167,7 +167,11 @@ #define MEDIUM_BREAK_MSECS 2500 #define LARGE_BREAK_MSECS 5000 +static PConstString ApplicationScope("application"); +static PConstString DialogScope("dialog"); +static PConstString PropertyScope("property"); + ////////////////////////////////////////////////////////// PVXMLPlayable::PVXMLPlayable() @@ -759,6 +763,17 @@ , m_transferStatus(NotTransfering) , m_transferStartTime(0) { +#if P_SCRIPTS + m_scriptContext = PScriptLanguage::Create("Java"); + if (m_scriptContext == NULL) + m_scriptContext = PScriptLanguage::Create("Lua"); // Back up + if (m_scriptContext != NULL) { + m_scriptContext->CreateComposite(ApplicationScope); + m_scriptContext->CreateComposite(DialogScope); + m_scriptContext->CreateComposite(PropertyScope); + } +#endif + SetVar("property.timeout" , "10s"); SetVar("property.bargein", "true"); } @@ -770,6 +785,10 @@ if (m_autoDeleteTextToSpeech) delete m_textToSpeech; + +#if P_SCRIPTS + delete m_scriptContext; +#endif } @@ -913,7 +932,7 @@ return false; } - m_variableScope = m_variableScope.IsEmpty() ? "application" : "document"; + m_variableScope = m_variableScope.IsEmpty() ? ApplicationScope : "document"; PURL pathURL = m_rootURL; pathURL.ChangePath(PString::Empty()); // Remove last element of root URL @@ -1495,6 +1514,16 @@ PString PVXMLSession::EvaluateExpr(const PString & expr) { +#if P_SCRIPTS + if (m_scriptContext != NULL) { + static PConstString const EvalVarName("PTLibEvaluateExpressionResult"); + if (m_scriptContext->Run(PSTRSTRM(EvalVarName<<'='<<expr))) + return m_scriptContext->GetString(EvalVarName); + PTRACE(2, "VXML\tCould not evaluate expression \"" << expr << "\" with script language " << m_scriptContext->GetLanguageName()); + return PString::Empty(); + } +#endif + // Should be full ECMAScript but ... // We only support expressions of the form 'literal'+variable or all digits @@ -1544,6 +1573,11 @@ if (varName.Find('.') == P_MAX_INDEX) fullVarName = m_variableScope+'.'+varName; +#if P_SCRIPTS + if (m_scriptContext != NULL) + return m_scriptContext->GetString(fullVarName); +#endif + return m_variables(fullVarName); } @@ -1554,6 +1588,11 @@ if (varName.Find('.') == P_MAX_INDEX) fullVarName = m_variableScope+'.'+varName; +#if P_SCRIPTS + if (m_scriptContext != NULL) + m_scriptContext->SetString(fullVarName, value); +#endif + m_variables.SetAt(fullVarName, value); } @@ -2268,14 +2307,14 @@ PBoolean PVXMLSession::TraverseForm(PXMLElement &) { - m_variableScope = "dialog"; + m_variableScope = DialogScope; return true; } PBoolean PVXMLSession::TraversedForm(PXMLElement &) { - m_variableScope = "application"; + m_variableScope = ApplicationScope; return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rjo...@us...> - 2016-03-12 16:30:55
|
Revision: 34677 http://sourceforge.net/p/opalvoip/code/34677 Author: rjongbloed Date: 2016-03-12 16:30:53 +0000 (Sat, 12 Mar 2016) Log Message: ----------- Changed SIP authentication so that if INVITE to domain which was not registered, but we are asked for authentication, we use the credentials of the first registration current. While not guaranteed to work, it will under some odd circumstances (e.g. redirect which uses different address for same registrar/proxy) and will not cause any damage if it subsequently doesn't work. Modified Paths: -------------- opal/branches/v3_16/include/sip/handlers.h opal/branches/v3_16/src/sip/handlers.cxx opal/branches/v3_16/src/sip/sipep.cxx Modified: opal/branches/v3_16/include/sip/handlers.h =================================================================== --- opal/branches/v3_16/include/sip/handlers.h 2016-03-11 10:57:02 UTC (rev 34676) +++ opal/branches/v3_16/include/sip/handlers.h 2016-03-12 16:30:53 UTC (rev 34677) @@ -360,12 +360,6 @@ bool DeleteObjectsToBeRemoved() { return m_handlersList.DeleteObjectsToBeRemoved(); } - /** Get the first handler in the list. Further enumeration may be done by - the ++operator on the safe pointer. - */ - PSafePtr<SIPHandler> GetFirstHandler(PSafetyMode mode = PSafeReference) const - { return PSafePtr<SIPHandler>(m_handlersList, mode); } - /** * Return the number of registered accounts */ @@ -376,6 +370,17 @@ */ PStringList GetAddresses(bool includeOffline, SIP_PDU::Methods meth, const PString & eventPackage = PString::Empty()) const; + /** Get the first handler in the list. Further enumeration may be done by + the ++operator on the safe pointer. + */ + PSafePtr<SIPHandler> GetFirstHandler(PSafetyMode mode = PSafeReference) const + { return PSafePtr<SIPHandler>(m_handlersList, mode); } + + /** Get the first handler in the list for the specified method. Further enumeration may be done by + the ++operator on the safe pointer. + */ + PSafePtr<SIPHandler> FindFirstHandler(SIP_PDU::Methods meth, PSafetyMode mode = PSafeReference) const; + /** * Find the SIPHandler object with the specified callID */ Modified: opal/branches/v3_16/src/sip/handlers.cxx =================================================================== --- opal/branches/v3_16/src/sip/handlers.cxx 2016-03-11 10:57:02 UTC (rev 34676) +++ opal/branches/v3_16/src/sip/handlers.cxx 2016-03-12 16:30:53 UTC (rev 34677) @@ -2506,6 +2506,16 @@ } +PSafePtr<SIPHandler> SIPHandlersList::FindFirstHandler(SIP_PDU::Methods meth, PSafetyMode mode) const +{ + PSafePtr<SIPHandler> handler(m_handlersList, PSafeReference); + while (handler != NULL && handler->GetMethod() != meth) + ++handler; + handler.SetSafetyMode(mode); + return handler; +} + + PSafePtr<SIPHandler> SIPHandlersList::FindSIPHandlerByCallID(const PString & callID, PSafetyMode mode) { return PSafePtrCast<SIPHandlerBase, SIPHandler>(m_handlersList.FindWithLock(callID, mode)); Modified: opal/branches/v3_16/src/sip/sipep.cxx =================================================================== --- opal/branches/v3_16/src/sip/sipep.cxx 2016-03-11 10:57:02 UTC (rev 34676) +++ opal/branches/v3_16/src/sip/sipep.cxx 2016-03-12 16:30:53 UTC (rev 34677) @@ -2063,8 +2063,11 @@ if (m_registeredUserMode) return false; - if ((handler = activeSIPHandlers.FindSIPHandlerByAuthRealm(realm, PSafeReadOnly)) == NULL) - return false; + if ((handler = activeSIPHandlers.FindSIPHandlerByAuthRealm(realm, PSafeReadOnly)) == NULL) { + if ((handler = activeSIPHandlers.FindFirstHandler(SIP_PDU::Method_REGISTER, PSafeReadOnly)) == NULL) + return false; + PTRACE(4, "Using first registrar " << handler->GetAddressOfRecord() << " for authentication"); + } } // really just after password, but username MAY change too. @@ -2153,9 +2156,7 @@ } else if (domain.IsEmpty() || OpalIsE164(domain)) { // No context, just get first registration - handler = activeSIPHandlers.GetFirstHandler(); - while (handler != NULL && handler->GetMethod() != SIP_PDU::Method_REGISTER) - ++handler; + handler = activeSIPHandlers.FindFirstHandler(SIP_PDU::Method_REGISTER); if (handler != NULL) { PTRACE(4, "Using first registrar " << handler->GetAddressOfRecord() << " for tel URI"); if (connection != NULL) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |