summaryrefslogtreecommitdiff
path: root/lib/avtp_pipeline/endpoint/openavb_endpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/avtp_pipeline/endpoint/openavb_endpoint.c')
-rw-r--r--lib/avtp_pipeline/endpoint/openavb_endpoint.c60
1 files changed, 39 insertions, 21 deletions
diff --git a/lib/avtp_pipeline/endpoint/openavb_endpoint.c b/lib/avtp_pipeline/endpoint/openavb_endpoint.c
index 5a4dfe17..30d8114a 100644
--- a/lib/avtp_pipeline/endpoint/openavb_endpoint.c
+++ b/lib/avtp_pipeline/endpoint/openavb_endpoint.c
@@ -1,16 +1,17 @@
/*************************************************************************************************************
Copyright (c) 2012-2015, Symphony Teleca Corporation, a Harman International Industries, Incorporated company
+Copyright (c) 2016-2017, Harman International Industries, Incorporated
All rights reserved.
-
+
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
-
+
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
-
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS LISTED "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -21,10 +22,10 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-Attributions: The inih library portion of the source code is licensed from
-Brush Technology and Ben Hoyt - Copyright (c) 2009, Brush Technology and Copyright (c) 2009, Ben Hoyt.
-Complete license and copyright information can be found at
+
+Attributions: The inih library portion of the source code is licensed from
+Brush Technology and Ben Hoyt - Copyright (c) 2009, Brush Technology and Copyright (c) 2009, Ben Hoyt.
+Complete license and copyright information can be found at
https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175.
*************************************************************************************************************/
@@ -33,7 +34,7 @@ https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175.
* It includes the SRP and QMgr libraries which handle SRP reservations
* and TX queuing.
*
-* The actual AVTP talker/listener work is done in a separate processs.
+* The actual AVTP talker/listener work is done in a separate process.
* The aim of using separate processes is to (1) reduce the
* complexity in the central process; and (2) to allow multiple types
* of children for different AVTP encapsulations and data sources.
@@ -59,6 +60,7 @@ https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175.
#include "openavb_avtp.h"
#include "openavb_qmgr.h"
#include "openavb_maap.h"
+#include "openavb_shaper.h"
#define AVB_LOG_COMPONENT "Endpoint"
#include "openavb_pub.h"
@@ -72,7 +74,7 @@ https://github.com/benhoyt/inih/commit/74d2ca064fb293bc60a77b0bd068075b293cf175.
clientStream_t* x_streamList;
// true until we are signalled to stop
bool endpointRunning = TRUE;
-// data from our configuation file
+// data from our configuration file
openavb_endpoint_cfg_t x_cfg;
/*************************************************************
@@ -135,7 +137,7 @@ clientStream_t* addStream(int h, AVBStreamID_t *streamID)
newClientStream->streamID.uniqueID = streamID->uniqueID;
newClientStream->clientHandle = h;
newClientStream->fwmark = INVALID_FWMARK;
-
+
if(x_streamList == NULL) {
x_streamList = newClientStream;
}else {
@@ -213,7 +215,7 @@ static clientStream_t* findStreamMaap(void* hndMaap)
{
AVB_TRACE_ENTRY(AVB_TRACE_ENDPOINT);
clientStream_t* ps = NULL;
-
+
clientStream_t **lpp;
for(lpp = &x_streamList; *lpp != NULL; lpp = &(*lpp)->next) {
if ((*lpp)->hndMaap == hndMaap)
@@ -229,7 +231,7 @@ static clientStream_t* findStreamMaap(void* hndMaap)
/*************************************************************
*
* Internal function to cleanup streams
- *
+ *
*/
bool x_talkerDeregister(clientStream_t *ps)
{
@@ -253,7 +255,13 @@ bool x_talkerDeregister(clientStream_t *ps)
openavbMaapRelease(ps->hndMaap);
ps->hndMaap = NULL;
}
-
+
+ // Finish Shaping
+ if (ps->hndShaper) {
+ openavbShaperRelease(ps->hndShaper);
+ ps->hndShaper = NULL;
+ }
+
// remove record
delStream(ps);
@@ -304,7 +312,7 @@ openavbRC strmAttachCb(void* pv,
|| lsnrDecl == openavbSrp_LDSt_Ready_Failed)
{
// Somebody is listening - get ready to stream
-
+
if (ps->fwmark != INVALID_FWMARK) {
AVB_LOG_DEBUG("attach callback: already setup queues");
rc = OPENAVB_SUCCESS;
@@ -346,6 +354,7 @@ openavbRC strmAttachCb(void* pv,
x_cfg.ifname,
ps->destAddr,
lsnrDecl,
+ ps->srClass,
ps->classRate,
ps->vlanID,
ps->priority,
@@ -397,7 +406,7 @@ openavbRC strmRegCb(void *pv,
*
* A better way to handle this would require SRP and the
* talkers/listeners to look at destination addresses (in addition
- * to StreamID and talker/listner declaration) and explicitly handle
+ * to StreamID and talker/listener declaration) and explicitly handle
* destination address changes.
*/
static void maapRestartCallback(void* handle, struct ether_addr *addr)
@@ -449,7 +458,7 @@ int avbEndpointLoop(void)
do {
if (!x_cfg.bypassAsCapableCheck && (startPTP() < 0)) {
- // make sure ptp, a seperate process, starts and is using the same interface as endpoint
+ // make sure ptp, a separate process, starts and is using the same interface as endpoint
AVB_LOG_ERROR("PTP failed to start - Exiting");
break;
} else if(x_cfg.bypassAsCapableCheck) {
@@ -457,7 +466,7 @@ int avbEndpointLoop(void)
AVB_LOG_WARNING("Configuration 'gptp_asCapable_not_required = 1' is set.");
AVB_LOG_WARNING("This configuration bypasses the requirement for gPTP");
AVB_LOG_WARNING("and openavb_gptp is not started automatically.");
- AVB_LOG_WARNING("An appropriate ptp MUST be started seperately.");
+ AVB_LOG_WARNING("An appropriate ptp MUST be started separately.");
AVB_LOG_WARNING("Any network which does not use ptp to synchronize time");
AVB_LOG_WARNING("on each and every network device is NOT an AVB network.");
AVB_LOG_WARNING("Such a network WILL NOT FUNCTION PROPERLY.");
@@ -471,12 +480,19 @@ int avbEndpointLoop(void)
break;
}
- if (!openavbMaapInitialize(x_cfg.ifname, maapRestartCallback)) {
+ if (!openavbMaapInitialize(x_cfg.ifname, x_cfg.maapPort, &(x_cfg.maap_preferred), maapRestartCallback)) {
AVB_LOG_ERROR("Failed to initialize MAAP");
openavbQmgrFinalize();
break;
}
+ if (!openavbShaperInitialize(x_cfg.ifname, x_cfg.shaperPort)) {
+ AVB_LOG_ERROR("Failed to initialize Shaper");
+ openavbMaapFinalize();
+ openavbQmgrFinalize();
+ break;
+ }
+
if(!x_cfg.noSrp) {
// Initialize SRP
rc = openavbSrpInitialize(strmAttachCb, strmRegCb, x_cfg.ifname, x_cfg.link_kbit, x_cfg.bypassAsCapableCheck);
@@ -493,6 +509,7 @@ int avbEndpointLoop(void)
if (!IS_OPENAVB_SUCCESS(rc)) {
AVB_LOG_ERROR("Failed to initialize SRP");
+ openavbShaperFinalize();
openavbMaapFinalize();
openavbQmgrFinalize();
break;
@@ -500,23 +517,24 @@ int avbEndpointLoop(void)
if (openavbEndpointServerOpen()) {
+ retVal = 0;
+
while (endpointRunning) {
openavbEptSrvrService();
}
openavbEndpointServerClose();
}
-
+
if(!x_cfg.noSrp) {
// Shutdown SRP
openavbSrpShutdown();
}
+ openavbShaperFinalize();
openavbMaapFinalize();
openavbQmgrFinalize();
- retVal = 0;
-
} while (0);
if (!x_cfg.bypassAsCapableCheck && (stopPTP() < 0)) {