Skip to content

Commit 5ff6604

Browse files
committed
GET_PARAM now callsback
Best I can tell, GET_PARAMETER is skipped being sent to callback because it is part of the heartbeat, and will get called every so often (current default 10s). I suppose I understand the intent, but not sure its the right approach, with the callback parameter, I want to see all traffic between server and client. Also if CSeq isn't in response, teardown() and raise error.
1 parent d9564db commit 5ff6604

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

rtsp.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,21 @@ def _get_time_str(self):
254254
def _process_response(self, msg):
255255
'''Process the response message'''
256256
status, headers, body = self._parse_response(msg)
257-
rsp_cseq = int(headers['cseq'])
258-
if self._cseq_map[rsp_cseq] != 'GET_PARAMETER':
257+
try:
258+
rsp_cseq = int(headers['cseq'])
259+
except KeyError as e:
259260
self._callback(self._get_time_str() + '\n' + msg)
261+
self.do_teardown()
262+
raise RTSPError('Unexpected response from server')
263+
264+
# Best I can tell, GET_PARAMETER is skipped being sent to callback
265+
# because it is part of the heartbeat, and will get called every so
266+
# often (current default 10s). I suppose I understand the intent, but
267+
# not sure its the right approach, with the callback parameter, I
268+
# want to see all traffic between server and client.
269+
#if self._cseq_map[rsp_cseq] != 'GET_PARAMETER':
270+
# self._callback(self._get_time_str() + '\n' + msg)
271+
self._callback(self._get_time_str() + '\n' + msg)
260272
if status == 401 and not self._auth:
261273
self._add_auth(headers['www-authenticate'])
262274
self.do_replay_request()
@@ -325,8 +337,9 @@ def _sendmsg(self, method, url, headers):
325337
for (k, v) in list(headers.items()):
326338
msg += END_OF_LINE + '%s: %s'%(k, str(v))
327339
msg += HEADER_END_STR # End headers
328-
if method != 'GET_PARAMETER' or 'x-RetransSeq' in headers:
329-
self._callback(self._get_time_str() + END_OF_LINE + msg)
340+
#if method != 'GET_PARAMETER' or 'x-RetransSeq' in headers:
341+
# self._callback(self._get_time_str() + END_OF_LINE + msg)
342+
self._callback(self._get_time_str() + END_OF_LINE + msg)
330343
try:
331344
self._sock.send(msg.encode())
332345
except socket.error as e:

0 commit comments

Comments
 (0)