Permalink
Browse files

Handle set chunk size messages. Enable RTMPClient to set application …

…name.
  • Loading branch information...
1 parent d06827d commit 0622c14a8ed30373597a5cb54b8b648bf91d3fd1 @prekageo committed Mar 26, 2012
Showing with 10 additions and 3 deletions.
  1. +9 −2 rtmp_protocol.py
  2. +1 −1 sample_rtmp_client.py
View
@@ -33,6 +33,7 @@ def at_eof(self):
class DataTypes:
""" Represents an enumeration of the RTMP message datatypes. """
NONE = -1
+ SET_CHUNK_SIZE = 1
USER_CONTROL = 4
WINDOW_ACK_SIZE = 5
SET_PEER_BANDWIDTH = 6
@@ -142,6 +143,8 @@ def next(self):
#elif ret['msg'] == DataTypes.NONE:
# print 'WARNING: message with no datatype received.', header
# return self.next()
+ elif ret['msg'] == DataTypes.SET_CHUNK_SIZE:
+ ret['chunk_size'] = body_stream.read_ulong()
else:
assert False, header
@@ -383,13 +386,14 @@ def on_message(self, data):
class RtmpClient:
""" Represents an RTMP client. """
- def __init__(self, ip, port, tc_url, page_url, swf_url):
+ def __init__(self, ip, port, tc_url, page_url, swf_url, app):
""" Initialize a new RTMP client. """
self.ip = ip
self.port = port
self.tc_url = tc_url
self.page_url = page_url
self.swf_url = swf_url
+ self.app = app
self.shared_objects = []
def handshake(self):
@@ -428,7 +432,7 @@ def connect_rtmp(self, connect_params):
'videoCodecs': 252,
'audioCodecs': 3191,
'flashVer': u'WIN 10,1,85,3',
- 'app': u'zoo_chat',
+ 'app': self.app,
'tcUrl': self.tc_url,
'videoFunction': 1,
'capabilities': 239,
@@ -464,6 +468,9 @@ def handle_message_pre_connect(self, msg):
elif msg['msg'] == DataTypes.USER_CONTROL:
assert msg['event_type'] == UserControlTypes.STREAM_BEGIN, msg
assert msg['event_data'] == '\x00\x00\x00\x00', msg
+ elif msg['msg'] == DataTypes.SET_CHUNK_SIZE:
+ assert msg['chunk_size'] > 0 and msg['chunk_size'] <= 65536, msg
+ self.reader.chunk_size = msg['chunk_size']
else:
assert False, msg
@@ -14,7 +14,7 @@ def main():
Start the client, connect to 127.0.0.1:80 and use 2 remote flash shared
objects.
"""
- client = rtmp_protocol.RtmpClient('127.0.0.1', 80, '', '', '')
+ client = rtmp_protocol.RtmpClient('127.0.0.1', 80, '', '', '', '')
client.connect([])
so_name = SO('so_name')

0 comments on commit 0622c14

Please sign in to comment.