RDK Documentation (Open Sourced RDK Components)
dtcpmgr.cpp
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 #include <iostream>
20 #include <stdio.h>
21 #include "dtcpmgr.h"
22 
23 static int started = 0;
24 static int initialized = 0;
25 typedef struct
26 {
27  int id;
29 
30 
32 {
33  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
34  if (initialized == 0)
35  {
36  printf("initialized Manager\n");
37  initialized = 1;
38  }
39  else
40  {
41  printf("Already initialized\n");
42  }
43  return DTCP_SUCCESS;
44 }
45 
46 dtcp_result_t DTCPMgrStartSource(char* ifName, int portNum)
47 {
48  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
49  printf("invoked start source with IFNAME: %s , port number: %d\n",ifName,portNum);
50  return DTCP_SUCCESS;
51 }
52 
54 {
55  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
56  if (initialized == 1)
57  {
58  printf("stopped DTCP Manager\n");
59  initialized = 0;
60  }
61  else
62  {
63  printf ("Already stopped\n");
64  }
65  return DTCP_SUCCESS;
66 }
67 
68 
70  int key_label,
71  int PCPPacketSize,
72  int maxPacketSize,
73  DTCP_SESSION_HANDLE *handle)
74 {
75  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
76  printf("invoked create source session with sinkIP: %s ; key label: %d,PCPPacketSize = %d, MaxPAcketSize = %d\n",
77  sinkIpAddress,
78  key_label,
79  PCPPacketSize,
80  maxPacketSize);
81  sessionHandle* lochandle = new sessionHandle;
82  lochandle->id = 1;
83  handle = (DTCP_SESSION_HANDLE*)(lochandle);
84  return DTCP_SUCCESS;
85 }
86 
88  int srcIpPort,
89  BOOLEAN uniqueKey,
90  int maxPacketSize,
91  DTCP_SESSION_HANDLE *handle)
92 {
93  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
94  printf("invoked create sink session with srcIP: %s ; srcIpPort: %d,uniqueKey = %c, MaxPAcketSize = %d\n",
95  srcIpAddress,
96  srcIpPort,
97  uniqueKey,
98  maxPacketSize);
99  sessionHandle* lochandle = new sessionHandle;
100  lochandle->id = 2;
101  handle = (DTCP_SESSION_HANDLE*)lochandle;
102  return DTCP_SUCCESS;
103 }
104 
105 
107 {
108  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
109  sessionHandle* locHandle = (sessionHandle*)&session;
110  printf("Enetered with sessionId = %d\n",locHandle->id);
111  return DTCP_SUCCESS;
112 }
113 
114 
116 {
117  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
118  return DTCP_SUCCESS;
119 }
120 
122 {
123  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
124  sessionHandle* locHandle = (sessionHandle*) &session;
125  delete locHandle;
126  return DTCP_SUCCESS;
127 }
128 
129 
131 {
132  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
133  return 1;
134 }
135 
136 
138 {
139  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
140  sessionHandle* locHandle = new sessionHandle;
141  session = new DTCPIP_Session;
142  session->session_handle = handle;
143  return DTCP_SUCCESS;
144 }
145 
147 {
148  printf("Entered fucntion %s\n",__PRETTY_FUNCTION__);
149  return DTCP_SUCCESS;
150 }
DTCPMgrInitialize
dtcp_result_t DTCPMgrInitialize(void)
Initializes the DTCP Manager.
Definition: dtcpmgr.cpp:31
dtcp_result_t
dtcp_result_t
DTCP Manager return codes.
Definition: dtcpmgr.h:148
BOOLEAN
unsigned char BOOLEAN
DTCP Manager return codes.
Definition: dtcpmgr.h:163
DTCPDeviceType
DTCPDeviceType
DTCP-IP device types.
Definition: dtcpmgr.h:177
sessionHandle
Definition: dtcpmgr.cpp:25
DTCPIP_Session_s::session_handle
DTCP_SESSION_HANDLE session_handle
Definition: dtcpmgr.h:215
DTCPMgrDeleteDTCPSession
dtcp_result_t DTCPMgrDeleteDTCPSession(DTCP_SESSION_HANDLE session)
Deletes a DTCP-IP session.
Definition: dtcpmgr.cpp:121
DTCPIP_Session
struct DTCPIP_Session_s DTCPIP_Session
DTCP-IP session structure.
DTCPMgrCreateSourceSession
dtcp_result_t DTCPMgrCreateSourceSession(char *sinkIpAddress, int key_label, int PCPPacketSize, int maxPacketSize, DTCP_SESSION_HANDLE *handle)
Creates a new DTCP-IP source session.
Definition: dtcpmgr.cpp:69
DTCPMgrReleasePacket
dtcp_result_t DTCPMgrReleasePacket(DTCPIP_Packet *packet)
Releases a processed DTCP-IP packet.
Definition: dtcpmgr.cpp:115
DTCP_SUCCESS
@ DTCP_SUCCESS
Definition: dtcpmgr.h:149
dtcpmgr.h
DTCPMgrStartSource
dtcp_result_t DTCPMgrStartSource(char *ifName, int portNum)
Starts the DTCP-IP source.
Definition: dtcpmgr.cpp:46
DTCPMgrStopSource
dtcp_result_t DTCPMgrStopSource(void)
Stops the DTCP-IP source.
Definition: dtcpmgr.cpp:53
DTCPIP_Session_s
DTCP-IP session structure.
Definition: dtcpmgr.h:213
DTCPMgrGetNumSessions
int DTCPMgrGetNumSessions(DTCPDeviceType deviceType)
Gets the number of active sessions.
Definition: dtcpmgr.cpp:130
DTCPMgrProcessPacket
dtcp_result_t DTCPMgrProcessPacket(DTCP_SESSION_HANDLE session, DTCPIP_Packet *packet)
Processes a DTCP-IP packet.
Definition: dtcpmgr.cpp:106
DTCPIP_Packet_s
DTCP-IP packet stucture.
Definition: dtcpmgr.h:188
DTCP_SESSION_HANDLE
unsigned long DTCP_SESSION_HANDLE
DTCP-IP session handle.
Definition: dtcpmgr.h:170
DTCPMgrSetLogLevel
dtcp_result_t DTCPMgrSetLogLevel(int level)
Sets log level.
Definition: dtcpmgr.cpp:146
DTCPMgrGetSessionInfo
dtcp_result_t DTCPMgrGetSessionInfo(DTCP_SESSION_HANDLE handle, DTCPIP_Session *session)
Gets session information.
Definition: dtcpmgr.cpp:137
DTCPMgrCreateSinkSession
dtcp_result_t DTCPMgrCreateSinkSession(char *srcIpAddress, int srcIpPort, BOOLEAN uniqueKey, int maxPacketSize, DTCP_SESSION_HANDLE *handle)
Creates a new DTCP-IP sink session.
Definition: dtcpmgr.cpp:87