<!DOCTYPE html>
<!-- saved from url=(0061)http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 
 <meta name="ROBOTS" content="NOARCHIVE">
 
 <link rel="icon" type="image/vnd.microsoft.icon" href="http://www.gstatic.com/codesite/ph/images/phosting.ico">
 
 
 <script src="./rtmp_files/cb=gapi.loaded0" async=""></script><script type="text/javascript" async="" src="./rtmp_files/plusone.js" gapi_processed="true"></script><script type="text/javascript">
 
 
 
 
 var codesite_token = "vVg-YEkpsP38PydkCFlVS-ioMOA:1335711600965";
 
 
 var CS_env = {"profileUrl":["/u/102069584091941751068/"],"token":"vVg-YEkpsP38PydkCFlVS-ioMOA:1335711600965","assetHostPath":"http://www.gstatic.com/codesite/ph","domainName":null,"assetVersionPath":"http://www.gstatic.com/codesite/ph/12151595242108277468","projectHomeUrl":"/p/rtmplite","relativeBaseUrl":"","projectName":"rtmplite","loggedInUserEmail":"arutyunyan.roman@gmail.com"};
 var _gaq = _gaq || [];
 _gaq.push(
 ['siteTracker._setAccount', 'UA-18071-1'],
 ['siteTracker._trackPageview']);
 
 
 </script>
 
 
 <title>rtmp.py - 
 rtmplite -
 
 
 Flash RTMP server in Python - Google Project Hosting
 </title>
 <link type="text/css" rel="stylesheet" href="./rtmp_files/core.css">
 
 <link type="text/css" rel="stylesheet" href="./rtmp_files/ph_detail.css">
 
 
 <link type="text/css" rel="stylesheet" href="./rtmp_files/d_sb.css">
 
 
 
<!--[if IE]>
 <link type="text/css" rel="stylesheet" href="http://www.gstatic.com/codesite/ph/12151595242108277468/css/d_ie.css" >
<![endif]-->
 <style type="text/css">
 .menuIcon.off { background: no-repeat url(http://www.gstatic.com/codesite/ph/images/dropdown_sprite.gif) 0 -42px }
 .menuIcon.on { background: no-repeat url(http://www.gstatic.com/codesite/ph/images/dropdown_sprite.gif) 0 -28px }
 .menuIcon.down { background: no-repeat url(http://www.gstatic.com/codesite/ph/images/dropdown_sprite.gif) 0 0; }
 
 
 
  tr.inline_comment {
 background: #fff;
 vertical-align: top;
 }
 div.draft, div.published {
 padding: .3em;
 border: 1px solid #999; 
 margin-bottom: .1em;
 font-family: arial, sans-serif;
 max-width: 60em;
 }
 div.draft {
 background: #ffa;
 } 
 div.published {
 background: #e5ecf9;
 }
 div.published .body, div.draft .body {
 padding: .5em .1em .1em .1em;
 max-width: 60em;
 white-space: pre-wrap;
 white-space: -moz-pre-wrap;
 white-space: -pre-wrap;
 white-space: -o-pre-wrap;
 word-wrap: break-word;
 font-size: 1em;
 }
 div.draft .actions {
 margin-left: 1em;
 font-size: 90%;
 }
 div.draft form {
 padding: .5em .5em .5em 0;
 }
 div.draft textarea, div.published textarea {
 width: 95%;
 height: 10em;
 font-family: arial, sans-serif;
 margin-bottom: .5em;
 }

 
 .nocursor, .nocursor td, .cursor_hidden, .cursor_hidden td {
 background-color: white;
 height: 2px;
 }
 .cursor, .cursor td {
 background-color: darkblue;
 height: 2px;
 display: '';
 }
 
 
.list {
 border: 1px solid white;
 border-bottom: 0;
}

 
 </style>
<script type="text/javascript" async="" src="./rtmp_files/ga.js"></script></head>
<body class="t4">
<script type="text/javascript">
 (function() {
 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
 (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
 })();
</script>
<script type="text/javascript">
 window.___gcfg = {lang: 'en'};
 (function() 
 {var po = document.createElement("script");
 po.type = "text/javascript"; po.async = true;po.src = "https://apis.google.com/js/plusone.js";
 var s = document.getElementsByTagName("script")[0];
 s.parentNode.insertBefore(po, s);
 })();
</script>
<div class="headbg">

 <div id="gaia">
 

 <span>
 
 
 <b>arutyunyan.roman@gmail.com</b>
 
 
 | <a href="http://code.google.com/u/102069584091941751068/" id="projects-dropdown" onclick="return false;"><u>My favorites</u> <small>▼</small></a>
 | <a href="http://code.google.com/u/102069584091941751068/" onclick="_CS_click(&#39;/gb/ph/profile&#39;);" title="Profile, Updates, and Settings"><u>Profile</u></a>
 | <a href="https://www.google.com/accounts/Logout?continue=http%3A%2F%2Fcode.google.com%2Fp%2Frtmplite%2Fsource%2Fbrowse%2Ftrunk%2Frtmp.py" onclick="_CS_click(&#39;/gb/ph/signout&#39;);"><u>Sign out</u></a>
 
 </span>

 </div>

 <div class="gbh" style="left: 0pt;"></div>
 <div class="gbh" style="right: 0pt;"></div>
 
 
 <div style="height: 1px"></div>
<!--[if lte IE 7]>
<div style="text-align:center;">
Your version of Internet Explorer is not supported. Try a browser that
contributes to open source, such as <a href="http://www.firefox.com">Firefox</a>,
<a href="http://www.google.com/chrome">Google Chrome</a>, or
<a href="http://code.google.com/chrome/chromeframe/">Google Chrome Frame</a>.
</div>
<![endif]-->



 <table style="padding:0px; margin: 0px 0px 10px 0px; width:100%" cellpadding="0" cellspacing="0" itemscope="" itemtype="http://schema.org/CreativeWork">
 <tbody><tr style="height: 58px;">
 
 <td id="plogo">
 <link itemprop="url" href="http://code.google.com/p/rtmplite">
 <a href="http://code.google.com/p/rtmplite/">
 
 
 <img src="./rtmp_files/logo" alt="Logo" itemprop="image">
 
 </a>
 </td>
 
 <td style="padding-left: 0.5em">
 
 <div id="pname">
 <a href="http://code.google.com/p/rtmplite/"><span itemprop="name">rtmplite</span></a>
 </div>
 
 <div id="psum">
 <a id="project_summary_link" href="http://code.google.com/p/rtmplite/"><span itemprop="description">Flash RTMP server in Python</span></a>
 
 </div>
 
 
 </td>
 <td style="white-space:nowrap;text-align:right; vertical-align:bottom;">
 
 <form action="http://code.google.com/hosting/search">
 <input size="30" name="q" value="" type="text">
 
 <input type="submit" name="projectsearch" value="Search projects">
 </form>
 
 </td></tr>
 </tbody></table>

</div>

 
<div id="mt" class="gtb"> 
 <a href="http://code.google.com/p/rtmplite/" class="tab ">Project&nbsp;Home</a>
 
 
 
 
 <a href="http://code.google.com/p/rtmplite/downloads/list" class="tab ">Downloads</a>
 
 
 
 
 
 <a href="http://code.google.com/p/rtmplite/w/list" class="tab ">Wiki</a>
 
 
 
 
 
 <a href="http://code.google.com/p/rtmplite/issues/list" class="tab ">Issues</a>
 
 
 
 
 
 <a href="http://code.google.com/p/rtmplite/source/checkout" class="tab active">Source</a>
 
 
 
 
 
 <div class="gtbc"></div>
</div>
<table cellspacing="0" cellpadding="0" width="100%" align="center" border="0" class="st">
 <tbody><tr>
 
 
 
 
 
 
 <td class="subt">
 <div class="st2">
 <div class="isf">
 
 


 <span class="inst1"><a href="http://code.google.com/p/rtmplite/source/checkout">Checkout</a></span> &nbsp;
 <span class="inst2"><a href="http://code.google.com/p/rtmplite/source/browse/trunk">Browse</a></span> &nbsp;
 <span class="inst3"><a href="http://code.google.com/p/rtmplite/source/list">Changes</a></span> &nbsp;
 
 &nbsp;
 
 <form action="http://code.google.com/p/rtmplite/source/search" method="get" style="display:inline" onsubmit="document.getElementById(&#39;codesearchq&#39;).value = document.getElementById(&#39;origq&#39;).value">
 <input type="hidden" name="q" id="codesearchq" value="">
 <input type="text" maxlength="2048" size="38" id="origq" name="origq" value="" title="Google Code Search" style="font-size:92%">&nbsp;<input type="submit" value="Search Trunk" name="btnG" style="font-size:92%">
 
 
 
 
 
 
 </form>
 </div>
</div>

 </td>
 
 
 
 <td align="right" valign="top" class="bevel-right"></td>
 </tr>
</tbody></table>


<script type="text/javascript">
 var cancelBubble = false;
 function _go(url) { document.location = url; }
</script>
<div id="maincol">

 
<!-- IE -->




<div class="expand">
<div id="colcontrol">
<style type="text/css">
 #file_flipper { white-space: nowrap; padding-right: 2em; }
 #file_flipper.hidden { display: none; }
 #file_flipper .pagelink { color: #0000CC; text-decoration: underline; }
 #file_flipper #visiblefiles { padding-left: 0.5em; padding-right: 0.5em; }
</style>
<table id="nav_and_rev" class="list" cellpadding="0" cellspacing="0" width="100%">
 <tbody><tr>
 
 <td nowrap="nowrap" class="src_crumbs src_nav" width="33%">
 <strong class="src_nav">Source path:&nbsp;</strong>
 <span id="crumb_root">
 
 <a href="http://code.google.com/p/rtmplite/source/browse/">svn</a>/&nbsp;</span>
 <span id="crumb_links" class="ifClosed"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/">trunk</a><span class="sp">/&nbsp;</span>rtmp.py</span>
 
 

 </td>
 
 
 <td nowrap="nowrap" width="33%" align="center">
 <a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py?edit=1"><img src="./rtmp_files/pencil-y14.png" class="edit_icon">Edit file</a>
 </td>
 
 
 <td nowrap="nowrap" width="33%" align="right">
 <table cellpadding="0" cellspacing="0" style="font-size: 100%"><tbody><tr>
 
 
 <td class="flipper">
 <ul class="leftside">
 
 <li><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py?r=142" title="Previous">‹r142</a></li>
 
 </ul>
 </td>
 
 <td class="flipper"><b>r154</b></td>
 
 </tr></tbody></table>
 </td> 
 </tr>
</tbody></table>

<div class="fc">
 
 
 
<style type="text/css">
.undermouse span {
 background-image: url(http://www.gstatic.com/codesite/ph/images/comments.gif); }
</style>
<table class="opened" id="review_comment_area"><tbody><tr>
<td id="nums">
<pre><table width="100%"><tbody><tr class="nocursor"><td></td></tr></tbody></table></pre>
<pre><table width="100%" id="nums_table_0"><tbody><tr id="gr_svn154_1"><td id="1"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1">1</a></td></tr><tr id="gr_svn154_2"><td id="2"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#2">2</a></td></tr><tr id="gr_svn154_3"><td id="3"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#3">3</a></td></tr><tr id="gr_svn154_4"><td id="4"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#4">4</a></td></tr><tr id="gr_svn154_5"><td id="5"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#5">5</a></td></tr><tr id="gr_svn154_6"><td id="6"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#6">6</a></td></tr><tr id="gr_svn154_7"><td id="7"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#7">7</a></td></tr><tr id="gr_svn154_8"><td id="8"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#8">8</a></td></tr><tr id="gr_svn154_9"><td id="9"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#9">9</a></td></tr><tr id="gr_svn154_10"><td id="10"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#10">10</a></td></tr><tr id="gr_svn154_11"><td id="11"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#11">11</a></td></tr><tr id="gr_svn154_12"><td id="12"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#12">12</a></td></tr><tr id="gr_svn154_13"><td id="13"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#13">13</a></td></tr><tr id="gr_svn154_14"><td id="14"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#14">14</a></td></tr><tr id="gr_svn154_15"><td id="15"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#15">15</a></td></tr><tr id="gr_svn154_16"><td id="16"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#16">16</a></td></tr><tr id="gr_svn154_17"><td id="17"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#17">17</a></td></tr><tr id="gr_svn154_18"><td id="18"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#18">18</a></td></tr><tr id="gr_svn154_19"><td id="19"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#19">19</a></td></tr><tr id="gr_svn154_20"><td id="20"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#20">20</a></td></tr><tr id="gr_svn154_21"><td id="21"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#21">21</a></td></tr><tr id="gr_svn154_22"><td id="22"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#22">22</a></td></tr><tr id="gr_svn154_23"><td id="23"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#23">23</a></td></tr><tr id="gr_svn154_24"><td id="24"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#24">24</a></td></tr><tr id="gr_svn154_25"><td id="25"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#25">25</a></td></tr><tr id="gr_svn154_26"><td id="26"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#26">26</a></td></tr><tr id="gr_svn154_27"><td id="27"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#27">27</a></td></tr><tr id="gr_svn154_28"><td id="28"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#28">28</a></td></tr><tr id="gr_svn154_29"><td id="29"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#29">29</a></td></tr><tr id="gr_svn154_30"><td id="30"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#30">30</a></td></tr><tr id="gr_svn154_31"><td id="31"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#31">31</a></td></tr><tr id="gr_svn154_32"><td id="32"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#32">32</a></td></tr><tr id="gr_svn154_33"><td id="33"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#33">33</a></td></tr><tr id="gr_svn154_34"><td id="34"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#34">34</a></td></tr><tr id="gr_svn154_35"><td id="35"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#35">35</a></td></tr><tr id="gr_svn154_36"><td id="36"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#36">36</a></td></tr><tr id="gr_svn154_37"><td id="37"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#37">37</a></td></tr><tr id="gr_svn154_38"><td id="38"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#38">38</a></td></tr><tr id="gr_svn154_39"><td id="39"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#39">39</a></td></tr><tr id="gr_svn154_40"><td id="40"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#40">40</a></td></tr><tr id="gr_svn154_41"><td id="41"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#41">41</a></td></tr><tr id="gr_svn154_42"><td id="42"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#42">42</a></td></tr><tr id="gr_svn154_43"><td id="43"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#43">43</a></td></tr><tr id="gr_svn154_44"><td id="44"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#44">44</a></td></tr><tr id="gr_svn154_45"><td id="45"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#45">45</a></td></tr><tr id="gr_svn154_46"><td id="46"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#46">46</a></td></tr><tr id="gr_svn154_47"><td id="47"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#47">47</a></td></tr><tr id="gr_svn154_48"><td id="48"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#48">48</a></td></tr><tr id="gr_svn154_49"><td id="49"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#49">49</a></td></tr><tr id="gr_svn154_50"><td id="50"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#50">50</a></td></tr><tr id="gr_svn154_51"><td id="51"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#51">51</a></td></tr><tr id="gr_svn154_52"><td id="52"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#52">52</a></td></tr><tr id="gr_svn154_53"><td id="53"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#53">53</a></td></tr><tr id="gr_svn154_54"><td id="54"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#54">54</a></td></tr><tr id="gr_svn154_55"><td id="55"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#55">55</a></td></tr><tr id="gr_svn154_56"><td id="56"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#56">56</a></td></tr><tr id="gr_svn154_57"><td id="57"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#57">57</a></td></tr><tr id="gr_svn154_58"><td id="58"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#58">58</a></td></tr><tr id="gr_svn154_59"><td id="59"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#59">59</a></td></tr><tr id="gr_svn154_60"><td id="60"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#60">60</a></td></tr><tr id="gr_svn154_61"><td id="61"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#61">61</a></td></tr><tr id="gr_svn154_62"><td id="62"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#62">62</a></td></tr><tr id="gr_svn154_63"><td id="63"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#63">63</a></td></tr><tr id="gr_svn154_64"><td id="64"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#64">64</a></td></tr><tr id="gr_svn154_65"><td id="65"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#65">65</a></td></tr><tr id="gr_svn154_66"><td id="66"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#66">66</a></td></tr><tr id="gr_svn154_67"><td id="67"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#67">67</a></td></tr><tr id="gr_svn154_68"><td id="68"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#68">68</a></td></tr><tr id="gr_svn154_69"><td id="69"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#69">69</a></td></tr><tr id="gr_svn154_70"><td id="70"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#70">70</a></td></tr><tr id="gr_svn154_71"><td id="71"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#71">71</a></td></tr><tr id="gr_svn154_72"><td id="72"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#72">72</a></td></tr><tr id="gr_svn154_73"><td id="73"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#73">73</a></td></tr><tr id="gr_svn154_74"><td id="74"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#74">74</a></td></tr><tr id="gr_svn154_75"><td id="75"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#75">75</a></td></tr><tr id="gr_svn154_76"><td id="76"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#76">76</a></td></tr><tr id="gr_svn154_77"><td id="77"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#77">77</a></td></tr><tr id="gr_svn154_78"><td id="78"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#78">78</a></td></tr><tr id="gr_svn154_79"><td id="79"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#79">79</a></td></tr><tr id="gr_svn154_80"><td id="80"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#80">80</a></td></tr><tr id="gr_svn154_81"><td id="81"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#81">81</a></td></tr><tr id="gr_svn154_82"><td id="82"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#82">82</a></td></tr><tr id="gr_svn154_83"><td id="83"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#83">83</a></td></tr><tr id="gr_svn154_84"><td id="84"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#84">84</a></td></tr><tr id="gr_svn154_85"><td id="85"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#85">85</a></td></tr><tr id="gr_svn154_86"><td id="86"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#86">86</a></td></tr><tr id="gr_svn154_87"><td id="87"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#87">87</a></td></tr><tr id="gr_svn154_88"><td id="88"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#88">88</a></td></tr><tr id="gr_svn154_89"><td id="89"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#89">89</a></td></tr><tr id="gr_svn154_90"><td id="90"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#90">90</a></td></tr><tr id="gr_svn154_91"><td id="91"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#91">91</a></td></tr><tr id="gr_svn154_92"><td id="92"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#92">92</a></td></tr><tr id="gr_svn154_93"><td id="93"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#93">93</a></td></tr><tr id="gr_svn154_94"><td id="94"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#94">94</a></td></tr><tr id="gr_svn154_95"><td id="95"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#95">95</a></td></tr><tr id="gr_svn154_96"><td id="96"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#96">96</a></td></tr><tr id="gr_svn154_97"><td id="97"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#97">97</a></td></tr><tr id="gr_svn154_98"><td id="98"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#98">98</a></td></tr><tr id="gr_svn154_99"><td id="99"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#99">99</a></td></tr><tr id="gr_svn154_100"><td id="100"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#100">100</a></td></tr><tr id="gr_svn154_101"><td id="101"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#101">101</a></td></tr><tr id="gr_svn154_102"><td id="102"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#102">102</a></td></tr><tr id="gr_svn154_103"><td id="103"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#103">103</a></td></tr><tr id="gr_svn154_104"><td id="104"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#104">104</a></td></tr><tr id="gr_svn154_105"><td id="105"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#105">105</a></td></tr><tr id="gr_svn154_106"><td id="106"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#106">106</a></td></tr><tr id="gr_svn154_107"><td id="107"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#107">107</a></td></tr><tr id="gr_svn154_108"><td id="108"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#108">108</a></td></tr><tr id="gr_svn154_109"><td id="109"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#109">109</a></td></tr><tr id="gr_svn154_110"><td id="110"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#110">110</a></td></tr><tr id="gr_svn154_111"><td id="111"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#111">111</a></td></tr><tr id="gr_svn154_112"><td id="112"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#112">112</a></td></tr><tr id="gr_svn154_113"><td id="113"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#113">113</a></td></tr><tr id="gr_svn154_114"><td id="114"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#114">114</a></td></tr><tr id="gr_svn154_115"><td id="115"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#115">115</a></td></tr><tr id="gr_svn154_116"><td id="116"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#116">116</a></td></tr><tr id="gr_svn154_117"><td id="117"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#117">117</a></td></tr><tr id="gr_svn154_118"><td id="118"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#118">118</a></td></tr><tr id="gr_svn154_119"><td id="119"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#119">119</a></td></tr><tr id="gr_svn154_120"><td id="120"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#120">120</a></td></tr><tr id="gr_svn154_121"><td id="121"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#121">121</a></td></tr><tr id="gr_svn154_122"><td id="122"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#122">122</a></td></tr><tr id="gr_svn154_123"><td id="123"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#123">123</a></td></tr><tr id="gr_svn154_124"><td id="124"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#124">124</a></td></tr><tr id="gr_svn154_125"><td id="125"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#125">125</a></td></tr><tr id="gr_svn154_126"><td id="126"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#126">126</a></td></tr><tr id="gr_svn154_127"><td id="127"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#127">127</a></td></tr><tr id="gr_svn154_128"><td id="128"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#128">128</a></td></tr><tr id="gr_svn154_129"><td id="129"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#129">129</a></td></tr><tr id="gr_svn154_130"><td id="130"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#130">130</a></td></tr><tr id="gr_svn154_131"><td id="131"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#131">131</a></td></tr><tr id="gr_svn154_132"><td id="132"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#132">132</a></td></tr><tr id="gr_svn154_133"><td id="133"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#133">133</a></td></tr><tr id="gr_svn154_134"><td id="134"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#134">134</a></td></tr><tr id="gr_svn154_135"><td id="135"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#135">135</a></td></tr><tr id="gr_svn154_136"><td id="136"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#136">136</a></td></tr><tr id="gr_svn154_137"><td id="137"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#137">137</a></td></tr><tr id="gr_svn154_138"><td id="138"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#138">138</a></td></tr><tr id="gr_svn154_139"><td id="139"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#139">139</a></td></tr><tr id="gr_svn154_140"><td id="140"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#140">140</a></td></tr><tr id="gr_svn154_141"><td id="141"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#141">141</a></td></tr><tr id="gr_svn154_142"><td id="142"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#142">142</a></td></tr><tr id="gr_svn154_143"><td id="143"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#143">143</a></td></tr><tr id="gr_svn154_144"><td id="144"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#144">144</a></td></tr><tr id="gr_svn154_145"><td id="145"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#145">145</a></td></tr><tr id="gr_svn154_146"><td id="146"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#146">146</a></td></tr><tr id="gr_svn154_147"><td id="147"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#147">147</a></td></tr><tr id="gr_svn154_148"><td id="148"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#148">148</a></td></tr><tr id="gr_svn154_149"><td id="149"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#149">149</a></td></tr><tr id="gr_svn154_150"><td id="150"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#150">150</a></td></tr><tr id="gr_svn154_151"><td id="151"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#151">151</a></td></tr><tr id="gr_svn154_152"><td id="152"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#152">152</a></td></tr><tr id="gr_svn154_153"><td id="153"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#153">153</a></td></tr><tr id="gr_svn154_154"><td id="154"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#154">154</a></td></tr><tr id="gr_svn154_155"><td id="155"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#155">155</a></td></tr><tr id="gr_svn154_156"><td id="156"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#156">156</a></td></tr><tr id="gr_svn154_157"><td id="157"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#157">157</a></td></tr><tr id="gr_svn154_158"><td id="158"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#158">158</a></td></tr><tr id="gr_svn154_159"><td id="159"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#159">159</a></td></tr><tr id="gr_svn154_160"><td id="160"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#160">160</a></td></tr><tr id="gr_svn154_161"><td id="161"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#161">161</a></td></tr><tr id="gr_svn154_162"><td id="162"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#162">162</a></td></tr><tr id="gr_svn154_163"><td id="163"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#163">163</a></td></tr><tr id="gr_svn154_164"><td id="164"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#164">164</a></td></tr><tr id="gr_svn154_165"><td id="165"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#165">165</a></td></tr><tr id="gr_svn154_166"><td id="166"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#166">166</a></td></tr><tr id="gr_svn154_167"><td id="167"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#167">167</a></td></tr><tr id="gr_svn154_168"><td id="168"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#168">168</a></td></tr><tr id="gr_svn154_169"><td id="169"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#169">169</a></td></tr><tr id="gr_svn154_170"><td id="170"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#170">170</a></td></tr><tr id="gr_svn154_171"><td id="171"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#171">171</a></td></tr><tr id="gr_svn154_172"><td id="172"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#172">172</a></td></tr><tr id="gr_svn154_173"><td id="173"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#173">173</a></td></tr><tr id="gr_svn154_174"><td id="174"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#174">174</a></td></tr><tr id="gr_svn154_175"><td id="175"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#175">175</a></td></tr><tr id="gr_svn154_176"><td id="176"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#176">176</a></td></tr><tr id="gr_svn154_177"><td id="177"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#177">177</a></td></tr><tr id="gr_svn154_178"><td id="178"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#178">178</a></td></tr><tr id="gr_svn154_179"><td id="179"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#179">179</a></td></tr><tr id="gr_svn154_180"><td id="180"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#180">180</a></td></tr><tr id="gr_svn154_181"><td id="181"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#181">181</a></td></tr><tr id="gr_svn154_182"><td id="182"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#182">182</a></td></tr><tr id="gr_svn154_183"><td id="183"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#183">183</a></td></tr><tr id="gr_svn154_184"><td id="184"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#184">184</a></td></tr><tr id="gr_svn154_185"><td id="185"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#185">185</a></td></tr><tr id="gr_svn154_186"><td id="186"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#186">186</a></td></tr><tr id="gr_svn154_187"><td id="187"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#187">187</a></td></tr><tr id="gr_svn154_188"><td id="188"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#188">188</a></td></tr><tr id="gr_svn154_189"><td id="189"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#189">189</a></td></tr><tr id="gr_svn154_190"><td id="190"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#190">190</a></td></tr><tr id="gr_svn154_191"><td id="191"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#191">191</a></td></tr><tr id="gr_svn154_192"><td id="192"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#192">192</a></td></tr><tr id="gr_svn154_193"><td id="193"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#193">193</a></td></tr><tr id="gr_svn154_194"><td id="194"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#194">194</a></td></tr><tr id="gr_svn154_195"><td id="195"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#195">195</a></td></tr><tr id="gr_svn154_196"><td id="196"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#196">196</a></td></tr><tr id="gr_svn154_197"><td id="197"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#197">197</a></td></tr><tr id="gr_svn154_198"><td id="198"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#198">198</a></td></tr><tr id="gr_svn154_199"><td id="199"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#199">199</a></td></tr><tr id="gr_svn154_200"><td id="200"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#200">200</a></td></tr><tr id="gr_svn154_201"><td id="201"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#201">201</a></td></tr><tr id="gr_svn154_202"><td id="202"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#202">202</a></td></tr><tr id="gr_svn154_203"><td id="203"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#203">203</a></td></tr><tr id="gr_svn154_204"><td id="204"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#204">204</a></td></tr><tr id="gr_svn154_205"><td id="205"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#205">205</a></td></tr><tr id="gr_svn154_206"><td id="206"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#206">206</a></td></tr><tr id="gr_svn154_207"><td id="207"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#207">207</a></td></tr><tr id="gr_svn154_208"><td id="208"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#208">208</a></td></tr><tr id="gr_svn154_209"><td id="209"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#209">209</a></td></tr><tr id="gr_svn154_210"><td id="210"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#210">210</a></td></tr><tr id="gr_svn154_211"><td id="211"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#211">211</a></td></tr><tr id="gr_svn154_212"><td id="212"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#212">212</a></td></tr><tr id="gr_svn154_213"><td id="213"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#213">213</a></td></tr><tr id="gr_svn154_214"><td id="214"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#214">214</a></td></tr><tr id="gr_svn154_215"><td id="215"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#215">215</a></td></tr><tr id="gr_svn154_216"><td id="216"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#216">216</a></td></tr><tr id="gr_svn154_217"><td id="217"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#217">217</a></td></tr><tr id="gr_svn154_218"><td id="218"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#218">218</a></td></tr><tr id="gr_svn154_219"><td id="219"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#219">219</a></td></tr><tr id="gr_svn154_220"><td id="220"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#220">220</a></td></tr><tr id="gr_svn154_221"><td id="221"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#221">221</a></td></tr><tr id="gr_svn154_222"><td id="222"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#222">222</a></td></tr><tr id="gr_svn154_223"><td id="223"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#223">223</a></td></tr><tr id="gr_svn154_224"><td id="224"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#224">224</a></td></tr><tr id="gr_svn154_225"><td id="225"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#225">225</a></td></tr><tr id="gr_svn154_226"><td id="226"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#226">226</a></td></tr><tr id="gr_svn154_227"><td id="227"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#227">227</a></td></tr><tr id="gr_svn154_228"><td id="228"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#228">228</a></td></tr><tr id="gr_svn154_229"><td id="229"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#229">229</a></td></tr><tr id="gr_svn154_230"><td id="230"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#230">230</a></td></tr><tr id="gr_svn154_231"><td id="231"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#231">231</a></td></tr><tr id="gr_svn154_232"><td id="232"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#232">232</a></td></tr><tr id="gr_svn154_233"><td id="233"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#233">233</a></td></tr><tr id="gr_svn154_234"><td id="234"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#234">234</a></td></tr><tr id="gr_svn154_235"><td id="235"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#235">235</a></td></tr><tr id="gr_svn154_236"><td id="236" style="height: 30px; "><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#236">236</a></td></tr><tr id="gr_svn154_237"><td id="237"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#237">237</a></td></tr><tr id="gr_svn154_238"><td id="238"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#238">238</a></td></tr><tr id="gr_svn154_239"><td id="239"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#239">239</a></td></tr><tr id="gr_svn154_240"><td id="240"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#240">240</a></td></tr><tr id="gr_svn154_241"><td id="241"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#241">241</a></td></tr><tr id="gr_svn154_242"><td id="242"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#242">242</a></td></tr><tr id="gr_svn154_243"><td id="243"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#243">243</a></td></tr><tr id="gr_svn154_244"><td id="244"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#244">244</a></td></tr><tr id="gr_svn154_245"><td id="245"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#245">245</a></td></tr><tr id="gr_svn154_246"><td id="246"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#246">246</a></td></tr><tr id="gr_svn154_247"><td id="247"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#247">247</a></td></tr><tr id="gr_svn154_248"><td id="248"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#248">248</a></td></tr><tr id="gr_svn154_249"><td id="249"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#249">249</a></td></tr><tr id="gr_svn154_250"><td id="250"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#250">250</a></td></tr><tr id="gr_svn154_251"><td id="251"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#251">251</a></td></tr><tr id="gr_svn154_252"><td id="252"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#252">252</a></td></tr><tr id="gr_svn154_253"><td id="253"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#253">253</a></td></tr><tr id="gr_svn154_254"><td id="254"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#254">254</a></td></tr><tr id="gr_svn154_255"><td id="255"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#255">255</a></td></tr><tr id="gr_svn154_256"><td id="256"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#256">256</a></td></tr><tr id="gr_svn154_257"><td id="257"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#257">257</a></td></tr><tr id="gr_svn154_258"><td id="258"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#258">258</a></td></tr><tr id="gr_svn154_259"><td id="259"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#259">259</a></td></tr><tr id="gr_svn154_260"><td id="260"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#260">260</a></td></tr><tr id="gr_svn154_261"><td id="261"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#261">261</a></td></tr><tr id="gr_svn154_262"><td id="262"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#262">262</a></td></tr><tr id="gr_svn154_263"><td id="263"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#263">263</a></td></tr><tr id="gr_svn154_264"><td id="264"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#264">264</a></td></tr><tr id="gr_svn154_265"><td id="265"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#265">265</a></td></tr><tr id="gr_svn154_266"><td id="266"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#266">266</a></td></tr><tr id="gr_svn154_267"><td id="267"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#267">267</a></td></tr><tr id="gr_svn154_268"><td id="268"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#268">268</a></td></tr><tr id="gr_svn154_269"><td id="269"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#269">269</a></td></tr><tr id="gr_svn154_270"><td id="270"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#270">270</a></td></tr><tr id="gr_svn154_271"><td id="271"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#271">271</a></td></tr><tr id="gr_svn154_272"><td id="272"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#272">272</a></td></tr><tr id="gr_svn154_273"><td id="273"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#273">273</a></td></tr><tr id="gr_svn154_274"><td id="274"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#274">274</a></td></tr><tr id="gr_svn154_275"><td id="275"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#275">275</a></td></tr><tr id="gr_svn154_276"><td id="276"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#276">276</a></td></tr><tr id="gr_svn154_277"><td id="277"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#277">277</a></td></tr><tr id="gr_svn154_278"><td id="278"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#278">278</a></td></tr><tr id="gr_svn154_279"><td id="279"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#279">279</a></td></tr><tr id="gr_svn154_280"><td id="280"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#280">280</a></td></tr><tr id="gr_svn154_281"><td id="281"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#281">281</a></td></tr><tr id="gr_svn154_282"><td id="282"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#282">282</a></td></tr><tr id="gr_svn154_283"><td id="283"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#283">283</a></td></tr><tr id="gr_svn154_284"><td id="284"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#284">284</a></td></tr><tr id="gr_svn154_285"><td id="285"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#285">285</a></td></tr><tr id="gr_svn154_286"><td id="286"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#286">286</a></td></tr><tr id="gr_svn154_287"><td id="287"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#287">287</a></td></tr><tr id="gr_svn154_288"><td id="288"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#288">288</a></td></tr><tr id="gr_svn154_289"><td id="289"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#289">289</a></td></tr><tr id="gr_svn154_290"><td id="290"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#290">290</a></td></tr><tr id="gr_svn154_291"><td id="291"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#291">291</a></td></tr><tr id="gr_svn154_292"><td id="292"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#292">292</a></td></tr><tr id="gr_svn154_293"><td id="293"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#293">293</a></td></tr><tr id="gr_svn154_294"><td id="294"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#294">294</a></td></tr><tr id="gr_svn154_295"><td id="295"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#295">295</a></td></tr><tr id="gr_svn154_296"><td id="296"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#296">296</a></td></tr><tr id="gr_svn154_297"><td id="297"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#297">297</a></td></tr><tr id="gr_svn154_298"><td id="298"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#298">298</a></td></tr><tr id="gr_svn154_299"><td id="299"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#299">299</a></td></tr><tr id="gr_svn154_300"><td id="300"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#300">300</a></td></tr><tr id="gr_svn154_301"><td id="301"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#301">301</a></td></tr><tr id="gr_svn154_302"><td id="302"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#302">302</a></td></tr><tr id="gr_svn154_303"><td id="303"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#303">303</a></td></tr><tr id="gr_svn154_304"><td id="304"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#304">304</a></td></tr><tr id="gr_svn154_305"><td id="305"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#305">305</a></td></tr><tr id="gr_svn154_306"><td id="306"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#306">306</a></td></tr><tr id="gr_svn154_307"><td id="307"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#307">307</a></td></tr><tr id="gr_svn154_308"><td id="308"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#308">308</a></td></tr><tr id="gr_svn154_309"><td id="309"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#309">309</a></td></tr><tr id="gr_svn154_310"><td id="310"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#310">310</a></td></tr><tr id="gr_svn154_311"><td id="311"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#311">311</a></td></tr><tr id="gr_svn154_312"><td id="312"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#312">312</a></td></tr><tr id="gr_svn154_313"><td id="313"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#313">313</a></td></tr><tr id="gr_svn154_314"><td id="314"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#314">314</a></td></tr><tr id="gr_svn154_315"><td id="315"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#315">315</a></td></tr><tr id="gr_svn154_316"><td id="316"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#316">316</a></td></tr><tr id="gr_svn154_317"><td id="317"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#317">317</a></td></tr><tr id="gr_svn154_318"><td id="318"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#318">318</a></td></tr><tr id="gr_svn154_319"><td id="319"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#319">319</a></td></tr><tr id="gr_svn154_320"><td id="320"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#320">320</a></td></tr><tr id="gr_svn154_321"><td id="321"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#321">321</a></td></tr><tr id="gr_svn154_322"><td id="322"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#322">322</a></td></tr><tr id="gr_svn154_323"><td id="323"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#323">323</a></td></tr><tr id="gr_svn154_324"><td id="324"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#324">324</a></td></tr><tr id="gr_svn154_325"><td id="325"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#325">325</a></td></tr><tr id="gr_svn154_326"><td id="326"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#326">326</a></td></tr><tr id="gr_svn154_327"><td id="327"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#327">327</a></td></tr><tr id="gr_svn154_328"><td id="328"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#328">328</a></td></tr><tr id="gr_svn154_329"><td id="329"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#329">329</a></td></tr><tr id="gr_svn154_330"><td id="330"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#330">330</a></td></tr><tr id="gr_svn154_331"><td id="331"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#331">331</a></td></tr><tr id="gr_svn154_332"><td id="332"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#332">332</a></td></tr><tr id="gr_svn154_333"><td id="333"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#333">333</a></td></tr><tr id="gr_svn154_334"><td id="334"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#334">334</a></td></tr><tr id="gr_svn154_335"><td id="335"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#335">335</a></td></tr><tr id="gr_svn154_336"><td id="336"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#336">336</a></td></tr><tr id="gr_svn154_337"><td id="337"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#337">337</a></td></tr><tr id="gr_svn154_338"><td id="338"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#338">338</a></td></tr><tr id="gr_svn154_339"><td id="339"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#339">339</a></td></tr><tr id="gr_svn154_340"><td id="340"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#340">340</a></td></tr><tr id="gr_svn154_341"><td id="341"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#341">341</a></td></tr><tr id="gr_svn154_342"><td id="342"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#342">342</a></td></tr><tr id="gr_svn154_343"><td id="343"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#343">343</a></td></tr><tr id="gr_svn154_344"><td id="344"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#344">344</a></td></tr><tr id="gr_svn154_345"><td id="345"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#345">345</a></td></tr><tr id="gr_svn154_346"><td id="346"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#346">346</a></td></tr><tr id="gr_svn154_347"><td id="347"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#347">347</a></td></tr><tr id="gr_svn154_348"><td id="348"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#348">348</a></td></tr><tr id="gr_svn154_349"><td id="349"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#349">349</a></td></tr><tr id="gr_svn154_350"><td id="350"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#350">350</a></td></tr><tr id="gr_svn154_351"><td id="351"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#351">351</a></td></tr><tr id="gr_svn154_352"><td id="352"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#352">352</a></td></tr><tr id="gr_svn154_353"><td id="353"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#353">353</a></td></tr><tr id="gr_svn154_354"><td id="354"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#354">354</a></td></tr><tr id="gr_svn154_355"><td id="355"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#355">355</a></td></tr><tr id="gr_svn154_356"><td id="356"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#356">356</a></td></tr><tr id="gr_svn154_357"><td id="357"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#357">357</a></td></tr><tr id="gr_svn154_358"><td id="358"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#358">358</a></td></tr><tr id="gr_svn154_359"><td id="359"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#359">359</a></td></tr><tr id="gr_svn154_360"><td id="360"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#360">360</a></td></tr><tr id="gr_svn154_361"><td id="361"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#361">361</a></td></tr><tr id="gr_svn154_362"><td id="362"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#362">362</a></td></tr><tr id="gr_svn154_363"><td id="363"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#363">363</a></td></tr><tr id="gr_svn154_364"><td id="364"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#364">364</a></td></tr><tr id="gr_svn154_365"><td id="365"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#365">365</a></td></tr><tr id="gr_svn154_366"><td id="366"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#366">366</a></td></tr><tr id="gr_svn154_367"><td id="367"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#367">367</a></td></tr><tr id="gr_svn154_368"><td id="368"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#368">368</a></td></tr><tr id="gr_svn154_369"><td id="369"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#369">369</a></td></tr><tr id="gr_svn154_370"><td id="370"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#370">370</a></td></tr><tr id="gr_svn154_371"><td id="371"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#371">371</a></td></tr><tr id="gr_svn154_372"><td id="372"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#372">372</a></td></tr><tr id="gr_svn154_373"><td id="373"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#373">373</a></td></tr><tr id="gr_svn154_374"><td id="374"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#374">374</a></td></tr><tr id="gr_svn154_375"><td id="375"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#375">375</a></td></tr><tr id="gr_svn154_376"><td id="376"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#376">376</a></td></tr><tr id="gr_svn154_377"><td id="377"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#377">377</a></td></tr><tr id="gr_svn154_378"><td id="378"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#378">378</a></td></tr><tr id="gr_svn154_379"><td id="379"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#379">379</a></td></tr><tr id="gr_svn154_380"><td id="380"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#380">380</a></td></tr><tr id="gr_svn154_381"><td id="381"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#381">381</a></td></tr><tr id="gr_svn154_382"><td id="382"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#382">382</a></td></tr><tr id="gr_svn154_383"><td id="383"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#383">383</a></td></tr><tr id="gr_svn154_384"><td id="384"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#384">384</a></td></tr><tr id="gr_svn154_385"><td id="385"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#385">385</a></td></tr><tr id="gr_svn154_386"><td id="386"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#386">386</a></td></tr><tr id="gr_svn154_387"><td id="387"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#387">387</a></td></tr><tr id="gr_svn154_388"><td id="388"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#388">388</a></td></tr><tr id="gr_svn154_389"><td id="389"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#389">389</a></td></tr><tr id="gr_svn154_390"><td id="390"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#390">390</a></td></tr><tr id="gr_svn154_391"><td id="391"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#391">391</a></td></tr><tr id="gr_svn154_392"><td id="392"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#392">392</a></td></tr><tr id="gr_svn154_393"><td id="393"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#393">393</a></td></tr><tr id="gr_svn154_394"><td id="394"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#394">394</a></td></tr><tr id="gr_svn154_395"><td id="395"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#395">395</a></td></tr><tr id="gr_svn154_396"><td id="396"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#396">396</a></td></tr><tr id="gr_svn154_397"><td id="397"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#397">397</a></td></tr><tr id="gr_svn154_398"><td id="398"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#398">398</a></td></tr><tr id="gr_svn154_399"><td id="399"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#399">399</a></td></tr><tr id="gr_svn154_400"><td id="400"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#400">400</a></td></tr><tr id="gr_svn154_401"><td id="401"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#401">401</a></td></tr><tr id="gr_svn154_402"><td id="402"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#402">402</a></td></tr><tr id="gr_svn154_403"><td id="403"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#403">403</a></td></tr><tr id="gr_svn154_404"><td id="404"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#404">404</a></td></tr><tr id="gr_svn154_405"><td id="405"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#405">405</a></td></tr><tr id="gr_svn154_406"><td id="406"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#406">406</a></td></tr><tr id="gr_svn154_407"><td id="407"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#407">407</a></td></tr><tr id="gr_svn154_408"><td id="408"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#408">408</a></td></tr><tr id="gr_svn154_409"><td id="409"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#409">409</a></td></tr><tr id="gr_svn154_410"><td id="410"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#410">410</a></td></tr><tr id="gr_svn154_411"><td id="411"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#411">411</a></td></tr><tr id="gr_svn154_412"><td id="412"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#412">412</a></td></tr><tr id="gr_svn154_413"><td id="413"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#413">413</a></td></tr><tr id="gr_svn154_414"><td id="414"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#414">414</a></td></tr><tr id="gr_svn154_415"><td id="415"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#415">415</a></td></tr><tr id="gr_svn154_416"><td id="416"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#416">416</a></td></tr><tr id="gr_svn154_417"><td id="417"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#417">417</a></td></tr><tr id="gr_svn154_418"><td id="418"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#418">418</a></td></tr><tr id="gr_svn154_419"><td id="419"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#419">419</a></td></tr><tr id="gr_svn154_420"><td id="420"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#420">420</a></td></tr><tr id="gr_svn154_421"><td id="421"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#421">421</a></td></tr><tr id="gr_svn154_422"><td id="422"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#422">422</a></td></tr><tr id="gr_svn154_423"><td id="423"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#423">423</a></td></tr><tr id="gr_svn154_424"><td id="424"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#424">424</a></td></tr><tr id="gr_svn154_425"><td id="425"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#425">425</a></td></tr><tr id="gr_svn154_426"><td id="426"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#426">426</a></td></tr><tr id="gr_svn154_427"><td id="427"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#427">427</a></td></tr><tr id="gr_svn154_428"><td id="428"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#428">428</a></td></tr><tr id="gr_svn154_429"><td id="429"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#429">429</a></td></tr><tr id="gr_svn154_430"><td id="430"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#430">430</a></td></tr><tr id="gr_svn154_431"><td id="431"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#431">431</a></td></tr><tr id="gr_svn154_432"><td id="432"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#432">432</a></td></tr><tr id="gr_svn154_433"><td id="433"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#433">433</a></td></tr><tr id="gr_svn154_434"><td id="434"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#434">434</a></td></tr><tr id="gr_svn154_435"><td id="435"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#435">435</a></td></tr><tr id="gr_svn154_436"><td id="436"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#436">436</a></td></tr><tr id="gr_svn154_437"><td id="437"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#437">437</a></td></tr><tr id="gr_svn154_438"><td id="438"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#438">438</a></td></tr><tr id="gr_svn154_439"><td id="439"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#439">439</a></td></tr><tr id="gr_svn154_440"><td id="440"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#440">440</a></td></tr><tr id="gr_svn154_441"><td id="441"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#441">441</a></td></tr><tr id="gr_svn154_442"><td id="442"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#442">442</a></td></tr><tr id="gr_svn154_443"><td id="443"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#443">443</a></td></tr><tr id="gr_svn154_444"><td id="444"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#444">444</a></td></tr><tr id="gr_svn154_445"><td id="445"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#445">445</a></td></tr><tr id="gr_svn154_446"><td id="446"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#446">446</a></td></tr><tr id="gr_svn154_447"><td id="447"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#447">447</a></td></tr><tr id="gr_svn154_448"><td id="448"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#448">448</a></td></tr><tr id="gr_svn154_449"><td id="449"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#449">449</a></td></tr><tr id="gr_svn154_450"><td id="450"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#450">450</a></td></tr><tr id="gr_svn154_451"><td id="451"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#451">451</a></td></tr><tr id="gr_svn154_452"><td id="452"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#452">452</a></td></tr><tr id="gr_svn154_453"><td id="453"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#453">453</a></td></tr><tr id="gr_svn154_454"><td id="454"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#454">454</a></td></tr><tr id="gr_svn154_455"><td id="455"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#455">455</a></td></tr><tr id="gr_svn154_456"><td id="456"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#456">456</a></td></tr><tr id="gr_svn154_457"><td id="457"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#457">457</a></td></tr><tr id="gr_svn154_458"><td id="458"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#458">458</a></td></tr><tr id="gr_svn154_459"><td id="459"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#459">459</a></td></tr><tr id="gr_svn154_460"><td id="460"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#460">460</a></td></tr><tr id="gr_svn154_461"><td id="461"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#461">461</a></td></tr><tr id="gr_svn154_462"><td id="462"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#462">462</a></td></tr><tr id="gr_svn154_463"><td id="463"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#463">463</a></td></tr><tr id="gr_svn154_464"><td id="464"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#464">464</a></td></tr><tr id="gr_svn154_465"><td id="465"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#465">465</a></td></tr><tr id="gr_svn154_466"><td id="466"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#466">466</a></td></tr><tr id="gr_svn154_467"><td id="467"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#467">467</a></td></tr><tr id="gr_svn154_468"><td id="468"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#468">468</a></td></tr><tr id="gr_svn154_469"><td id="469"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#469">469</a></td></tr><tr id="gr_svn154_470"><td id="470"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#470">470</a></td></tr><tr id="gr_svn154_471"><td id="471"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#471">471</a></td></tr><tr id="gr_svn154_472"><td id="472"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#472">472</a></td></tr><tr id="gr_svn154_473"><td id="473"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#473">473</a></td></tr><tr id="gr_svn154_474"><td id="474"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#474">474</a></td></tr><tr id="gr_svn154_475"><td id="475"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#475">475</a></td></tr><tr id="gr_svn154_476"><td id="476"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#476">476</a></td></tr><tr id="gr_svn154_477"><td id="477"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#477">477</a></td></tr><tr id="gr_svn154_478"><td id="478"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#478">478</a></td></tr><tr id="gr_svn154_479"><td id="479"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#479">479</a></td></tr><tr id="gr_svn154_480"><td id="480"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#480">480</a></td></tr><tr id="gr_svn154_481"><td id="481"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#481">481</a></td></tr><tr id="gr_svn154_482"><td id="482"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#482">482</a></td></tr><tr id="gr_svn154_483"><td id="483"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#483">483</a></td></tr><tr id="gr_svn154_484"><td id="484"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#484">484</a></td></tr><tr id="gr_svn154_485"><td id="485"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#485">485</a></td></tr><tr id="gr_svn154_486"><td id="486"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#486">486</a></td></tr><tr id="gr_svn154_487"><td id="487"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#487">487</a></td></tr><tr id="gr_svn154_488"><td id="488"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#488">488</a></td></tr><tr id="gr_svn154_489"><td id="489"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#489">489</a></td></tr><tr id="gr_svn154_490"><td id="490"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#490">490</a></td></tr><tr id="gr_svn154_491"><td id="491"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#491">491</a></td></tr><tr id="gr_svn154_492"><td id="492"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#492">492</a></td></tr><tr id="gr_svn154_493"><td id="493"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#493">493</a></td></tr><tr id="gr_svn154_494"><td id="494"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#494">494</a></td></tr><tr id="gr_svn154_495"><td id="495"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#495">495</a></td></tr><tr id="gr_svn154_496"><td id="496"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#496">496</a></td></tr><tr id="gr_svn154_497"><td id="497"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#497">497</a></td></tr><tr id="gr_svn154_498"><td id="498"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#498">498</a></td></tr><tr id="gr_svn154_499"><td id="499"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#499">499</a></td></tr><tr id="gr_svn154_500"><td id="500"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#500">500</a></td></tr><tr id="gr_svn154_501"><td id="501"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#501">501</a></td></tr><tr id="gr_svn154_502"><td id="502"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#502">502</a></td></tr><tr id="gr_svn154_503"><td id="503"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#503">503</a></td></tr><tr id="gr_svn154_504"><td id="504"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#504">504</a></td></tr><tr id="gr_svn154_505"><td id="505"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#505">505</a></td></tr><tr id="gr_svn154_506"><td id="506"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#506">506</a></td></tr><tr id="gr_svn154_507"><td id="507"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#507">507</a></td></tr><tr id="gr_svn154_508"><td id="508"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#508">508</a></td></tr><tr id="gr_svn154_509"><td id="509"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#509">509</a></td></tr><tr id="gr_svn154_510"><td id="510"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#510">510</a></td></tr><tr id="gr_svn154_511"><td id="511"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#511">511</a></td></tr><tr id="gr_svn154_512"><td id="512"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#512">512</a></td></tr><tr id="gr_svn154_513"><td id="513"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#513">513</a></td></tr><tr id="gr_svn154_514"><td id="514"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#514">514</a></td></tr><tr id="gr_svn154_515"><td id="515"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#515">515</a></td></tr><tr id="gr_svn154_516"><td id="516"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#516">516</a></td></tr><tr id="gr_svn154_517"><td id="517"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#517">517</a></td></tr><tr id="gr_svn154_518"><td id="518"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#518">518</a></td></tr><tr id="gr_svn154_519"><td id="519"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#519">519</a></td></tr><tr id="gr_svn154_520"><td id="520"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#520">520</a></td></tr><tr id="gr_svn154_521"><td id="521"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#521">521</a></td></tr><tr id="gr_svn154_522"><td id="522"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#522">522</a></td></tr><tr id="gr_svn154_523"><td id="523"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#523">523</a></td></tr><tr id="gr_svn154_524"><td id="524"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#524">524</a></td></tr><tr id="gr_svn154_525"><td id="525"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#525">525</a></td></tr><tr id="gr_svn154_526"><td id="526"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#526">526</a></td></tr><tr id="gr_svn154_527"><td id="527"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#527">527</a></td></tr><tr id="gr_svn154_528"><td id="528"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#528">528</a></td></tr><tr id="gr_svn154_529"><td id="529"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#529">529</a></td></tr><tr id="gr_svn154_530"><td id="530"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#530">530</a></td></tr><tr id="gr_svn154_531"><td id="531"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#531">531</a></td></tr><tr id="gr_svn154_532"><td id="532"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#532">532</a></td></tr><tr id="gr_svn154_533"><td id="533"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#533">533</a></td></tr><tr id="gr_svn154_534"><td id="534"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#534">534</a></td></tr><tr id="gr_svn154_535"><td id="535"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#535">535</a></td></tr><tr id="gr_svn154_536"><td id="536"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#536">536</a></td></tr><tr id="gr_svn154_537"><td id="537"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#537">537</a></td></tr><tr id="gr_svn154_538"><td id="538"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#538">538</a></td></tr><tr id="gr_svn154_539"><td id="539"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#539">539</a></td></tr><tr id="gr_svn154_540"><td id="540"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#540">540</a></td></tr><tr id="gr_svn154_541"><td id="541"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#541">541</a></td></tr><tr id="gr_svn154_542"><td id="542"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#542">542</a></td></tr><tr id="gr_svn154_543"><td id="543"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#543">543</a></td></tr><tr id="gr_svn154_544"><td id="544"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#544">544</a></td></tr><tr id="gr_svn154_545"><td id="545"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#545">545</a></td></tr><tr id="gr_svn154_546"><td id="546"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#546">546</a></td></tr><tr id="gr_svn154_547"><td id="547"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#547">547</a></td></tr><tr id="gr_svn154_548"><td id="548"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#548">548</a></td></tr><tr id="gr_svn154_549"><td id="549"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#549">549</a></td></tr><tr id="gr_svn154_550"><td id="550"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#550">550</a></td></tr><tr id="gr_svn154_551"><td id="551"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#551">551</a></td></tr><tr id="gr_svn154_552"><td id="552"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#552">552</a></td></tr><tr id="gr_svn154_553"><td id="553"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#553">553</a></td></tr><tr id="gr_svn154_554"><td id="554"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#554">554</a></td></tr><tr id="gr_svn154_555"><td id="555"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#555">555</a></td></tr><tr id="gr_svn154_556"><td id="556"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#556">556</a></td></tr><tr id="gr_svn154_557"><td id="557"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#557">557</a></td></tr><tr id="gr_svn154_558"><td id="558"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#558">558</a></td></tr><tr id="gr_svn154_559"><td id="559"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#559">559</a></td></tr><tr id="gr_svn154_560"><td id="560"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#560">560</a></td></tr><tr id="gr_svn154_561"><td id="561"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#561">561</a></td></tr><tr id="gr_svn154_562"><td id="562"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#562">562</a></td></tr><tr id="gr_svn154_563"><td id="563"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#563">563</a></td></tr><tr id="gr_svn154_564"><td id="564"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#564">564</a></td></tr><tr id="gr_svn154_565"><td id="565"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#565">565</a></td></tr><tr id="gr_svn154_566"><td id="566"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#566">566</a></td></tr><tr id="gr_svn154_567"><td id="567"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#567">567</a></td></tr><tr id="gr_svn154_568"><td id="568"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#568">568</a></td></tr><tr id="gr_svn154_569"><td id="569"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#569">569</a></td></tr><tr id="gr_svn154_570"><td id="570"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#570">570</a></td></tr><tr id="gr_svn154_571"><td id="571"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#571">571</a></td></tr><tr id="gr_svn154_572"><td id="572"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#572">572</a></td></tr><tr id="gr_svn154_573"><td id="573"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#573">573</a></td></tr><tr id="gr_svn154_574"><td id="574"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#574">574</a></td></tr><tr id="gr_svn154_575"><td id="575"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#575">575</a></td></tr><tr id="gr_svn154_576"><td id="576"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#576">576</a></td></tr><tr id="gr_svn154_577"><td id="577"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#577">577</a></td></tr><tr id="gr_svn154_578"><td id="578"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#578">578</a></td></tr><tr id="gr_svn154_579"><td id="579"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#579">579</a></td></tr><tr id="gr_svn154_580"><td id="580"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#580">580</a></td></tr><tr id="gr_svn154_581"><td id="581"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#581">581</a></td></tr><tr id="gr_svn154_582"><td id="582"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#582">582</a></td></tr><tr id="gr_svn154_583"><td id="583"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#583">583</a></td></tr><tr id="gr_svn154_584"><td id="584"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#584">584</a></td></tr><tr id="gr_svn154_585"><td id="585"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#585">585</a></td></tr><tr id="gr_svn154_586"><td id="586"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#586">586</a></td></tr><tr id="gr_svn154_587"><td id="587"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#587">587</a></td></tr><tr id="gr_svn154_588"><td id="588"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#588">588</a></td></tr><tr id="gr_svn154_589"><td id="589"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#589">589</a></td></tr><tr id="gr_svn154_590"><td id="590"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#590">590</a></td></tr><tr id="gr_svn154_591"><td id="591"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#591">591</a></td></tr><tr id="gr_svn154_592"><td id="592"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#592">592</a></td></tr><tr id="gr_svn154_593"><td id="593"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#593">593</a></td></tr><tr id="gr_svn154_594"><td id="594"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#594">594</a></td></tr><tr id="gr_svn154_595"><td id="595"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#595">595</a></td></tr><tr id="gr_svn154_596"><td id="596"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#596">596</a></td></tr><tr id="gr_svn154_597"><td id="597"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#597">597</a></td></tr><tr id="gr_svn154_598"><td id="598"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#598">598</a></td></tr><tr id="gr_svn154_599"><td id="599"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#599">599</a></td></tr><tr id="gr_svn154_600"><td id="600"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#600">600</a></td></tr><tr id="gr_svn154_601"><td id="601"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#601">601</a></td></tr><tr id="gr_svn154_602"><td id="602"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#602">602</a></td></tr><tr id="gr_svn154_603"><td id="603"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#603">603</a></td></tr><tr id="gr_svn154_604"><td id="604"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#604">604</a></td></tr><tr id="gr_svn154_605"><td id="605"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#605">605</a></td></tr><tr id="gr_svn154_606"><td id="606"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#606">606</a></td></tr><tr id="gr_svn154_607"><td id="607"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#607">607</a></td></tr><tr id="gr_svn154_608"><td id="608"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#608">608</a></td></tr><tr id="gr_svn154_609"><td id="609"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#609">609</a></td></tr><tr id="gr_svn154_610"><td id="610"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#610">610</a></td></tr><tr id="gr_svn154_611"><td id="611"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#611">611</a></td></tr><tr id="gr_svn154_612"><td id="612"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#612">612</a></td></tr><tr id="gr_svn154_613"><td id="613"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#613">613</a></td></tr><tr id="gr_svn154_614"><td id="614"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#614">614</a></td></tr><tr id="gr_svn154_615"><td id="615"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#615">615</a></td></tr><tr id="gr_svn154_616"><td id="616"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#616">616</a></td></tr><tr id="gr_svn154_617"><td id="617"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#617">617</a></td></tr><tr id="gr_svn154_618"><td id="618"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#618">618</a></td></tr><tr id="gr_svn154_619"><td id="619"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#619">619</a></td></tr><tr id="gr_svn154_620"><td id="620"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#620">620</a></td></tr><tr id="gr_svn154_621"><td id="621"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#621">621</a></td></tr><tr id="gr_svn154_622"><td id="622"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#622">622</a></td></tr><tr id="gr_svn154_623"><td id="623"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#623">623</a></td></tr><tr id="gr_svn154_624"><td id="624"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#624">624</a></td></tr><tr id="gr_svn154_625"><td id="625"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#625">625</a></td></tr><tr id="gr_svn154_626"><td id="626"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#626">626</a></td></tr><tr id="gr_svn154_627"><td id="627"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#627">627</a></td></tr><tr id="gr_svn154_628"><td id="628"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#628">628</a></td></tr><tr id="gr_svn154_629"><td id="629"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#629">629</a></td></tr><tr id="gr_svn154_630"><td id="630"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#630">630</a></td></tr><tr id="gr_svn154_631"><td id="631"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#631">631</a></td></tr><tr id="gr_svn154_632"><td id="632"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#632">632</a></td></tr><tr id="gr_svn154_633"><td id="633"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#633">633</a></td></tr><tr id="gr_svn154_634"><td id="634"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#634">634</a></td></tr><tr id="gr_svn154_635"><td id="635"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#635">635</a></td></tr><tr id="gr_svn154_636"><td id="636"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#636">636</a></td></tr><tr id="gr_svn154_637"><td id="637"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#637">637</a></td></tr><tr id="gr_svn154_638"><td id="638"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#638">638</a></td></tr><tr id="gr_svn154_639"><td id="639"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#639">639</a></td></tr><tr id="gr_svn154_640"><td id="640"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#640">640</a></td></tr><tr id="gr_svn154_641"><td id="641"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#641">641</a></td></tr><tr id="gr_svn154_642"><td id="642"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#642">642</a></td></tr><tr id="gr_svn154_643"><td id="643"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#643">643</a></td></tr><tr id="gr_svn154_644"><td id="644"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#644">644</a></td></tr><tr id="gr_svn154_645"><td id="645"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#645">645</a></td></tr><tr id="gr_svn154_646"><td id="646"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#646">646</a></td></tr><tr id="gr_svn154_647"><td id="647"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#647">647</a></td></tr><tr id="gr_svn154_648"><td id="648"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#648">648</a></td></tr><tr id="gr_svn154_649"><td id="649"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#649">649</a></td></tr><tr id="gr_svn154_650"><td id="650"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#650">650</a></td></tr><tr id="gr_svn154_651"><td id="651"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#651">651</a></td></tr><tr id="gr_svn154_652"><td id="652"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#652">652</a></td></tr><tr id="gr_svn154_653"><td id="653"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#653">653</a></td></tr><tr id="gr_svn154_654"><td id="654"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#654">654</a></td></tr><tr id="gr_svn154_655"><td id="655"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#655">655</a></td></tr><tr id="gr_svn154_656"><td id="656"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#656">656</a></td></tr><tr id="gr_svn154_657"><td id="657"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#657">657</a></td></tr><tr id="gr_svn154_658"><td id="658"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#658">658</a></td></tr><tr id="gr_svn154_659"><td id="659"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#659">659</a></td></tr><tr id="gr_svn154_660"><td id="660"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#660">660</a></td></tr><tr id="gr_svn154_661"><td id="661"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#661">661</a></td></tr><tr id="gr_svn154_662"><td id="662"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#662">662</a></td></tr><tr id="gr_svn154_663"><td id="663"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#663">663</a></td></tr><tr id="gr_svn154_664"><td id="664"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#664">664</a></td></tr><tr id="gr_svn154_665"><td id="665"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#665">665</a></td></tr><tr id="gr_svn154_666"><td id="666"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#666">666</a></td></tr><tr id="gr_svn154_667"><td id="667"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#667">667</a></td></tr><tr id="gr_svn154_668"><td id="668"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#668">668</a></td></tr><tr id="gr_svn154_669"><td id="669"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#669">669</a></td></tr><tr id="gr_svn154_670"><td id="670"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#670">670</a></td></tr><tr id="gr_svn154_671"><td id="671"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#671">671</a></td></tr><tr id="gr_svn154_672"><td id="672"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#672">672</a></td></tr><tr id="gr_svn154_673"><td id="673"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#673">673</a></td></tr><tr id="gr_svn154_674"><td id="674"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#674">674</a></td></tr><tr id="gr_svn154_675"><td id="675"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#675">675</a></td></tr><tr id="gr_svn154_676"><td id="676"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#676">676</a></td></tr><tr id="gr_svn154_677"><td id="677"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#677">677</a></td></tr><tr id="gr_svn154_678"><td id="678"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#678">678</a></td></tr><tr id="gr_svn154_679"><td id="679"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#679">679</a></td></tr><tr id="gr_svn154_680"><td id="680"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#680">680</a></td></tr><tr id="gr_svn154_681"><td id="681"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#681">681</a></td></tr><tr id="gr_svn154_682"><td id="682"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#682">682</a></td></tr><tr id="gr_svn154_683"><td id="683"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#683">683</a></td></tr><tr id="gr_svn154_684"><td id="684"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#684">684</a></td></tr><tr id="gr_svn154_685"><td id="685"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#685">685</a></td></tr><tr id="gr_svn154_686"><td id="686"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#686">686</a></td></tr><tr id="gr_svn154_687"><td id="687"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#687">687</a></td></tr><tr id="gr_svn154_688"><td id="688"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#688">688</a></td></tr><tr id="gr_svn154_689"><td id="689"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#689">689</a></td></tr><tr id="gr_svn154_690"><td id="690"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#690">690</a></td></tr><tr id="gr_svn154_691"><td id="691"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#691">691</a></td></tr><tr id="gr_svn154_692"><td id="692"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#692">692</a></td></tr><tr id="gr_svn154_693"><td id="693"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#693">693</a></td></tr><tr id="gr_svn154_694"><td id="694"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#694">694</a></td></tr><tr id="gr_svn154_695"><td id="695"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#695">695</a></td></tr><tr id="gr_svn154_696"><td id="696"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#696">696</a></td></tr><tr id="gr_svn154_697"><td id="697"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#697">697</a></td></tr><tr id="gr_svn154_698"><td id="698"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#698">698</a></td></tr><tr id="gr_svn154_699"><td id="699"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#699">699</a></td></tr><tr id="gr_svn154_700"><td id="700"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#700">700</a></td></tr><tr id="gr_svn154_701"><td id="701"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#701">701</a></td></tr><tr id="gr_svn154_702"><td id="702"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#702">702</a></td></tr><tr id="gr_svn154_703"><td id="703"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#703">703</a></td></tr><tr id="gr_svn154_704"><td id="704"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#704">704</a></td></tr><tr id="gr_svn154_705"><td id="705"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#705">705</a></td></tr><tr id="gr_svn154_706"><td id="706"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#706">706</a></td></tr><tr id="gr_svn154_707"><td id="707"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#707">707</a></td></tr><tr id="gr_svn154_708"><td id="708"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#708">708</a></td></tr><tr id="gr_svn154_709"><td id="709"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#709">709</a></td></tr><tr id="gr_svn154_710"><td id="710"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#710">710</a></td></tr><tr id="gr_svn154_711"><td id="711"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#711">711</a></td></tr><tr id="gr_svn154_712"><td id="712"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#712">712</a></td></tr><tr id="gr_svn154_713"><td id="713"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#713">713</a></td></tr><tr id="gr_svn154_714"><td id="714"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#714">714</a></td></tr><tr id="gr_svn154_715"><td id="715"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#715">715</a></td></tr><tr id="gr_svn154_716"><td id="716"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#716">716</a></td></tr><tr id="gr_svn154_717"><td id="717"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#717">717</a></td></tr><tr id="gr_svn154_718"><td id="718"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#718">718</a></td></tr><tr id="gr_svn154_719"><td id="719"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#719">719</a></td></tr><tr id="gr_svn154_720"><td id="720"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#720">720</a></td></tr><tr id="gr_svn154_721"><td id="721"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#721">721</a></td></tr><tr id="gr_svn154_722"><td id="722"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#722">722</a></td></tr><tr id="gr_svn154_723"><td id="723"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#723">723</a></td></tr><tr id="gr_svn154_724"><td id="724"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#724">724</a></td></tr><tr id="gr_svn154_725"><td id="725"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#725">725</a></td></tr><tr id="gr_svn154_726"><td id="726"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#726">726</a></td></tr><tr id="gr_svn154_727"><td id="727"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#727">727</a></td></tr><tr id="gr_svn154_728"><td id="728"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#728">728</a></td></tr><tr id="gr_svn154_729"><td id="729"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#729">729</a></td></tr><tr id="gr_svn154_730"><td id="730"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#730">730</a></td></tr><tr id="gr_svn154_731"><td id="731"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#731">731</a></td></tr><tr id="gr_svn154_732"><td id="732"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#732">732</a></td></tr><tr id="gr_svn154_733"><td id="733"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#733">733</a></td></tr><tr id="gr_svn154_734"><td id="734"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#734">734</a></td></tr><tr id="gr_svn154_735"><td id="735"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#735">735</a></td></tr><tr id="gr_svn154_736"><td id="736"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#736">736</a></td></tr><tr id="gr_svn154_737"><td id="737"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#737">737</a></td></tr><tr id="gr_svn154_738"><td id="738"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#738">738</a></td></tr><tr id="gr_svn154_739"><td id="739"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#739">739</a></td></tr><tr id="gr_svn154_740"><td id="740"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#740">740</a></td></tr><tr id="gr_svn154_741"><td id="741"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#741">741</a></td></tr><tr id="gr_svn154_742"><td id="742"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#742">742</a></td></tr><tr id="gr_svn154_743"><td id="743"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#743">743</a></td></tr><tr id="gr_svn154_744"><td id="744"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#744">744</a></td></tr><tr id="gr_svn154_745"><td id="745"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#745">745</a></td></tr><tr id="gr_svn154_746"><td id="746"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#746">746</a></td></tr><tr id="gr_svn154_747"><td id="747"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#747">747</a></td></tr><tr id="gr_svn154_748"><td id="748"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#748">748</a></td></tr><tr id="gr_svn154_749"><td id="749"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#749">749</a></td></tr><tr id="gr_svn154_750"><td id="750"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#750">750</a></td></tr><tr id="gr_svn154_751"><td id="751"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#751">751</a></td></tr><tr id="gr_svn154_752"><td id="752"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#752">752</a></td></tr><tr id="gr_svn154_753"><td id="753"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#753">753</a></td></tr><tr id="gr_svn154_754"><td id="754"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#754">754</a></td></tr><tr id="gr_svn154_755"><td id="755"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#755">755</a></td></tr><tr id="gr_svn154_756"><td id="756"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#756">756</a></td></tr><tr id="gr_svn154_757"><td id="757"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#757">757</a></td></tr><tr id="gr_svn154_758"><td id="758"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#758">758</a></td></tr><tr id="gr_svn154_759"><td id="759"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#759">759</a></td></tr><tr id="gr_svn154_760"><td id="760"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#760">760</a></td></tr><tr id="gr_svn154_761"><td id="761"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#761">761</a></td></tr><tr id="gr_svn154_762"><td id="762"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#762">762</a></td></tr><tr id="gr_svn154_763"><td id="763"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#763">763</a></td></tr><tr id="gr_svn154_764"><td id="764"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#764">764</a></td></tr><tr id="gr_svn154_765"><td id="765"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#765">765</a></td></tr><tr id="gr_svn154_766"><td id="766"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#766">766</a></td></tr><tr id="gr_svn154_767"><td id="767"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#767">767</a></td></tr><tr id="gr_svn154_768"><td id="768"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#768">768</a></td></tr><tr id="gr_svn154_769"><td id="769"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#769">769</a></td></tr><tr id="gr_svn154_770"><td id="770"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#770">770</a></td></tr><tr id="gr_svn154_771"><td id="771"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#771">771</a></td></tr><tr id="gr_svn154_772"><td id="772"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#772">772</a></td></tr><tr id="gr_svn154_773"><td id="773"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#773">773</a></td></tr><tr id="gr_svn154_774"><td id="774"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#774">774</a></td></tr><tr id="gr_svn154_775"><td id="775"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#775">775</a></td></tr><tr id="gr_svn154_776"><td id="776"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#776">776</a></td></tr><tr id="gr_svn154_777"><td id="777"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#777">777</a></td></tr><tr id="gr_svn154_778"><td id="778"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#778">778</a></td></tr><tr id="gr_svn154_779"><td id="779"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#779">779</a></td></tr><tr id="gr_svn154_780"><td id="780"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#780">780</a></td></tr><tr id="gr_svn154_781"><td id="781"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#781">781</a></td></tr><tr id="gr_svn154_782"><td id="782"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#782">782</a></td></tr><tr id="gr_svn154_783"><td id="783"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#783">783</a></td></tr><tr id="gr_svn154_784"><td id="784"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#784">784</a></td></tr><tr id="gr_svn154_785"><td id="785"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#785">785</a></td></tr><tr id="gr_svn154_786"><td id="786"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#786">786</a></td></tr><tr id="gr_svn154_787"><td id="787"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#787">787</a></td></tr><tr id="gr_svn154_788"><td id="788"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#788">788</a></td></tr><tr id="gr_svn154_789"><td id="789"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#789">789</a></td></tr><tr id="gr_svn154_790"><td id="790"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#790">790</a></td></tr><tr id="gr_svn154_791"><td id="791"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#791">791</a></td></tr><tr id="gr_svn154_792"><td id="792"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#792">792</a></td></tr><tr id="gr_svn154_793"><td id="793"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#793">793</a></td></tr><tr id="gr_svn154_794"><td id="794"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#794">794</a></td></tr><tr id="gr_svn154_795"><td id="795"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#795">795</a></td></tr><tr id="gr_svn154_796"><td id="796"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#796">796</a></td></tr><tr id="gr_svn154_797"><td id="797"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#797">797</a></td></tr><tr id="gr_svn154_798"><td id="798"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#798">798</a></td></tr><tr id="gr_svn154_799"><td id="799"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#799">799</a></td></tr><tr id="gr_svn154_800"><td id="800"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#800">800</a></td></tr><tr id="gr_svn154_801"><td id="801"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#801">801</a></td></tr><tr id="gr_svn154_802"><td id="802"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#802">802</a></td></tr><tr id="gr_svn154_803"><td id="803"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#803">803</a></td></tr><tr id="gr_svn154_804"><td id="804"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#804">804</a></td></tr><tr id="gr_svn154_805"><td id="805"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#805">805</a></td></tr><tr id="gr_svn154_806"><td id="806"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#806">806</a></td></tr><tr id="gr_svn154_807"><td id="807"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#807">807</a></td></tr><tr id="gr_svn154_808"><td id="808"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#808">808</a></td></tr><tr id="gr_svn154_809"><td id="809"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#809">809</a></td></tr><tr id="gr_svn154_810"><td id="810"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#810">810</a></td></tr><tr id="gr_svn154_811"><td id="811"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#811">811</a></td></tr><tr id="gr_svn154_812"><td id="812"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#812">812</a></td></tr><tr id="gr_svn154_813"><td id="813"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#813">813</a></td></tr><tr id="gr_svn154_814"><td id="814"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#814">814</a></td></tr><tr id="gr_svn154_815"><td id="815"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#815">815</a></td></tr><tr id="gr_svn154_816"><td id="816"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#816">816</a></td></tr><tr id="gr_svn154_817"><td id="817"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#817">817</a></td></tr><tr id="gr_svn154_818"><td id="818"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#818">818</a></td></tr><tr id="gr_svn154_819"><td id="819"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#819">819</a></td></tr><tr id="gr_svn154_820"><td id="820"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#820">820</a></td></tr><tr id="gr_svn154_821"><td id="821"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#821">821</a></td></tr><tr id="gr_svn154_822"><td id="822"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#822">822</a></td></tr><tr id="gr_svn154_823"><td id="823"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#823">823</a></td></tr><tr id="gr_svn154_824"><td id="824"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#824">824</a></td></tr><tr id="gr_svn154_825"><td id="825"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#825">825</a></td></tr><tr id="gr_svn154_826"><td id="826"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#826">826</a></td></tr><tr id="gr_svn154_827"><td id="827"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#827">827</a></td></tr><tr id="gr_svn154_828"><td id="828"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#828">828</a></td></tr><tr id="gr_svn154_829"><td id="829"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#829">829</a></td></tr><tr id="gr_svn154_830"><td id="830"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#830">830</a></td></tr><tr id="gr_svn154_831"><td id="831"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#831">831</a></td></tr><tr id="gr_svn154_832"><td id="832"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#832">832</a></td></tr><tr id="gr_svn154_833"><td id="833"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#833">833</a></td></tr><tr id="gr_svn154_834"><td id="834"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#834">834</a></td></tr><tr id="gr_svn154_835"><td id="835"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#835">835</a></td></tr><tr id="gr_svn154_836"><td id="836"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#836">836</a></td></tr><tr id="gr_svn154_837"><td id="837"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#837">837</a></td></tr><tr id="gr_svn154_838"><td id="838"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#838">838</a></td></tr><tr id="gr_svn154_839"><td id="839"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#839">839</a></td></tr><tr id="gr_svn154_840"><td id="840"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#840">840</a></td></tr><tr id="gr_svn154_841"><td id="841"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#841">841</a></td></tr><tr id="gr_svn154_842"><td id="842"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#842">842</a></td></tr><tr id="gr_svn154_843"><td id="843"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#843">843</a></td></tr><tr id="gr_svn154_844"><td id="844"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#844">844</a></td></tr><tr id="gr_svn154_845"><td id="845"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#845">845</a></td></tr><tr id="gr_svn154_846"><td id="846"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#846">846</a></td></tr><tr id="gr_svn154_847"><td id="847"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#847">847</a></td></tr><tr id="gr_svn154_848"><td id="848"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#848">848</a></td></tr><tr id="gr_svn154_849"><td id="849"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#849">849</a></td></tr><tr id="gr_svn154_850"><td id="850"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#850">850</a></td></tr><tr id="gr_svn154_851"><td id="851"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#851">851</a></td></tr><tr id="gr_svn154_852"><td id="852"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#852">852</a></td></tr><tr id="gr_svn154_853"><td id="853"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#853">853</a></td></tr><tr id="gr_svn154_854"><td id="854"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#854">854</a></td></tr><tr id="gr_svn154_855"><td id="855"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#855">855</a></td></tr><tr id="gr_svn154_856"><td id="856"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#856">856</a></td></tr><tr id="gr_svn154_857"><td id="857"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#857">857</a></td></tr><tr id="gr_svn154_858"><td id="858"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#858">858</a></td></tr><tr id="gr_svn154_859"><td id="859"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#859">859</a></td></tr><tr id="gr_svn154_860"><td id="860"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#860">860</a></td></tr><tr id="gr_svn154_861"><td id="861"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#861">861</a></td></tr><tr id="gr_svn154_862"><td id="862"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#862">862</a></td></tr><tr id="gr_svn154_863"><td id="863"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#863">863</a></td></tr><tr id="gr_svn154_864"><td id="864"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#864">864</a></td></tr><tr id="gr_svn154_865"><td id="865"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#865">865</a></td></tr><tr id="gr_svn154_866"><td id="866"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#866">866</a></td></tr><tr id="gr_svn154_867"><td id="867"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#867">867</a></td></tr><tr id="gr_svn154_868"><td id="868"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#868">868</a></td></tr><tr id="gr_svn154_869"><td id="869"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#869">869</a></td></tr><tr id="gr_svn154_870"><td id="870"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#870">870</a></td></tr><tr id="gr_svn154_871"><td id="871"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#871">871</a></td></tr><tr id="gr_svn154_872"><td id="872"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#872">872</a></td></tr><tr id="gr_svn154_873"><td id="873"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#873">873</a></td></tr><tr id="gr_svn154_874"><td id="874"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#874">874</a></td></tr><tr id="gr_svn154_875"><td id="875"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#875">875</a></td></tr><tr id="gr_svn154_876"><td id="876"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#876">876</a></td></tr><tr id="gr_svn154_877"><td id="877"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#877">877</a></td></tr><tr id="gr_svn154_878"><td id="878"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#878">878</a></td></tr><tr id="gr_svn154_879"><td id="879"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#879">879</a></td></tr><tr id="gr_svn154_880"><td id="880"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#880">880</a></td></tr><tr id="gr_svn154_881"><td id="881"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#881">881</a></td></tr><tr id="gr_svn154_882"><td id="882"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#882">882</a></td></tr><tr id="gr_svn154_883"><td id="883"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#883">883</a></td></tr><tr id="gr_svn154_884"><td id="884"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#884">884</a></td></tr><tr id="gr_svn154_885"><td id="885"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#885">885</a></td></tr><tr id="gr_svn154_886"><td id="886"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#886">886</a></td></tr><tr id="gr_svn154_887"><td id="887"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#887">887</a></td></tr><tr id="gr_svn154_888"><td id="888"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#888">888</a></td></tr><tr id="gr_svn154_889"><td id="889"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#889">889</a></td></tr><tr id="gr_svn154_890"><td id="890"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#890">890</a></td></tr><tr id="gr_svn154_891"><td id="891"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#891">891</a></td></tr><tr id="gr_svn154_892"><td id="892"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#892">892</a></td></tr><tr id="gr_svn154_893"><td id="893"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#893">893</a></td></tr><tr id="gr_svn154_894"><td id="894"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#894">894</a></td></tr><tr id="gr_svn154_895"><td id="895"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#895">895</a></td></tr><tr id="gr_svn154_896"><td id="896"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#896">896</a></td></tr><tr id="gr_svn154_897"><td id="897"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#897">897</a></td></tr><tr id="gr_svn154_898"><td id="898"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#898">898</a></td></tr><tr id="gr_svn154_899"><td id="899"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#899">899</a></td></tr><tr id="gr_svn154_900"><td id="900"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#900">900</a></td></tr><tr id="gr_svn154_901"><td id="901"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#901">901</a></td></tr><tr id="gr_svn154_902"><td id="902"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#902">902</a></td></tr><tr id="gr_svn154_903"><td id="903"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#903">903</a></td></tr><tr id="gr_svn154_904"><td id="904"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#904">904</a></td></tr><tr id="gr_svn154_905"><td id="905"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#905">905</a></td></tr><tr id="gr_svn154_906"><td id="906"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#906">906</a></td></tr><tr id="gr_svn154_907"><td id="907"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#907">907</a></td></tr><tr id="gr_svn154_908"><td id="908"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#908">908</a></td></tr><tr id="gr_svn154_909"><td id="909"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#909">909</a></td></tr><tr id="gr_svn154_910"><td id="910"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#910">910</a></td></tr><tr id="gr_svn154_911"><td id="911"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#911">911</a></td></tr><tr id="gr_svn154_912"><td id="912"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#912">912</a></td></tr><tr id="gr_svn154_913"><td id="913"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#913">913</a></td></tr><tr id="gr_svn154_914"><td id="914"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#914">914</a></td></tr><tr id="gr_svn154_915"><td id="915"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#915">915</a></td></tr><tr id="gr_svn154_916"><td id="916"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#916">916</a></td></tr><tr id="gr_svn154_917"><td id="917"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#917">917</a></td></tr><tr id="gr_svn154_918"><td id="918"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#918">918</a></td></tr><tr id="gr_svn154_919"><td id="919"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#919">919</a></td></tr><tr id="gr_svn154_920"><td id="920"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#920">920</a></td></tr><tr id="gr_svn154_921"><td id="921"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#921">921</a></td></tr><tr id="gr_svn154_922"><td id="922"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#922">922</a></td></tr><tr id="gr_svn154_923"><td id="923"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#923">923</a></td></tr><tr id="gr_svn154_924"><td id="924"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#924">924</a></td></tr><tr id="gr_svn154_925"><td id="925"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#925">925</a></td></tr><tr id="gr_svn154_926"><td id="926"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#926">926</a></td></tr><tr id="gr_svn154_927"><td id="927"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#927">927</a></td></tr><tr id="gr_svn154_928"><td id="928"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#928">928</a></td></tr><tr id="gr_svn154_929"><td id="929"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#929">929</a></td></tr><tr id="gr_svn154_930"><td id="930"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#930">930</a></td></tr><tr id="gr_svn154_931"><td id="931"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#931">931</a></td></tr><tr id="gr_svn154_932"><td id="932"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#932">932</a></td></tr><tr id="gr_svn154_933"><td id="933"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#933">933</a></td></tr><tr id="gr_svn154_934"><td id="934"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#934">934</a></td></tr><tr id="gr_svn154_935"><td id="935"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#935">935</a></td></tr><tr id="gr_svn154_936"><td id="936"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#936">936</a></td></tr><tr id="gr_svn154_937"><td id="937"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#937">937</a></td></tr><tr id="gr_svn154_938"><td id="938"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#938">938</a></td></tr><tr id="gr_svn154_939"><td id="939"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#939">939</a></td></tr><tr id="gr_svn154_940"><td id="940"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#940">940</a></td></tr><tr id="gr_svn154_941"><td id="941"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#941">941</a></td></tr><tr id="gr_svn154_942"><td id="942"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#942">942</a></td></tr><tr id="gr_svn154_943"><td id="943"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#943">943</a></td></tr><tr id="gr_svn154_944"><td id="944"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#944">944</a></td></tr><tr id="gr_svn154_945"><td id="945"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#945">945</a></td></tr><tr id="gr_svn154_946"><td id="946"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#946">946</a></td></tr><tr id="gr_svn154_947"><td id="947"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#947">947</a></td></tr><tr id="gr_svn154_948"><td id="948"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#948">948</a></td></tr><tr id="gr_svn154_949"><td id="949"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#949">949</a></td></tr><tr id="gr_svn154_950"><td id="950"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#950">950</a></td></tr><tr id="gr_svn154_951"><td id="951"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#951">951</a></td></tr><tr id="gr_svn154_952"><td id="952"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#952">952</a></td></tr><tr id="gr_svn154_953"><td id="953"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#953">953</a></td></tr><tr id="gr_svn154_954"><td id="954"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#954">954</a></td></tr><tr id="gr_svn154_955"><td id="955"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#955">955</a></td></tr><tr id="gr_svn154_956"><td id="956"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#956">956</a></td></tr><tr id="gr_svn154_957"><td id="957"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#957">957</a></td></tr><tr id="gr_svn154_958"><td id="958"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#958">958</a></td></tr><tr id="gr_svn154_959"><td id="959"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#959">959</a></td></tr><tr id="gr_svn154_960"><td id="960"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#960">960</a></td></tr><tr id="gr_svn154_961"><td id="961"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#961">961</a></td></tr><tr id="gr_svn154_962"><td id="962"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#962">962</a></td></tr><tr id="gr_svn154_963"><td id="963"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#963">963</a></td></tr><tr id="gr_svn154_964"><td id="964"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#964">964</a></td></tr><tr id="gr_svn154_965"><td id="965"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#965">965</a></td></tr><tr id="gr_svn154_966"><td id="966"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#966">966</a></td></tr><tr id="gr_svn154_967"><td id="967"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#967">967</a></td></tr><tr id="gr_svn154_968"><td id="968"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#968">968</a></td></tr><tr id="gr_svn154_969"><td id="969"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#969">969</a></td></tr><tr id="gr_svn154_970"><td id="970"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#970">970</a></td></tr><tr id="gr_svn154_971"><td id="971"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#971">971</a></td></tr><tr id="gr_svn154_972"><td id="972"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#972">972</a></td></tr><tr id="gr_svn154_973"><td id="973"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#973">973</a></td></tr><tr id="gr_svn154_974"><td id="974"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#974">974</a></td></tr><tr id="gr_svn154_975"><td id="975"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#975">975</a></td></tr><tr id="gr_svn154_976"><td id="976"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#976">976</a></td></tr><tr id="gr_svn154_977"><td id="977"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#977">977</a></td></tr><tr id="gr_svn154_978"><td id="978"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#978">978</a></td></tr><tr id="gr_svn154_979"><td id="979"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#979">979</a></td></tr><tr id="gr_svn154_980"><td id="980"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#980">980</a></td></tr><tr id="gr_svn154_981"><td id="981"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#981">981</a></td></tr><tr id="gr_svn154_982"><td id="982"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#982">982</a></td></tr><tr id="gr_svn154_983"><td id="983"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#983">983</a></td></tr><tr id="gr_svn154_984"><td id="984"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#984">984</a></td></tr><tr id="gr_svn154_985"><td id="985"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#985">985</a></td></tr><tr id="gr_svn154_986"><td id="986"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#986">986</a></td></tr><tr id="gr_svn154_987"><td id="987"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#987">987</a></td></tr><tr id="gr_svn154_988"><td id="988"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#988">988</a></td></tr><tr id="gr_svn154_989"><td id="989"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#989">989</a></td></tr><tr id="gr_svn154_990"><td id="990"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#990">990</a></td></tr><tr id="gr_svn154_991"><td id="991"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#991">991</a></td></tr><tr id="gr_svn154_992"><td id="992"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#992">992</a></td></tr><tr id="gr_svn154_993"><td id="993"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#993">993</a></td></tr><tr id="gr_svn154_994"><td id="994"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#994">994</a></td></tr><tr id="gr_svn154_995"><td id="995"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#995">995</a></td></tr><tr id="gr_svn154_996"><td id="996"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#996">996</a></td></tr><tr id="gr_svn154_997"><td id="997"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#997">997</a></td></tr><tr id="gr_svn154_998"><td id="998"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#998">998</a></td></tr><tr id="gr_svn154_999"><td id="999"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#999">999</a></td></tr><tr id="gr_svn154_1000"><td id="1000"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1000">1000</a></td></tr><tr id="gr_svn154_1001"><td id="1001"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1001">1001</a></td></tr><tr id="gr_svn154_1002"><td id="1002"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1002">1002</a></td></tr><tr id="gr_svn154_1003"><td id="1003"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1003">1003</a></td></tr><tr id="gr_svn154_1004"><td id="1004"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1004">1004</a></td></tr><tr id="gr_svn154_1005"><td id="1005"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1005">1005</a></td></tr><tr id="gr_svn154_1006"><td id="1006"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1006">1006</a></td></tr><tr id="gr_svn154_1007"><td id="1007"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1007">1007</a></td></tr><tr id="gr_svn154_1008"><td id="1008"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1008">1008</a></td></tr><tr id="gr_svn154_1009"><td id="1009"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1009">1009</a></td></tr><tr id="gr_svn154_1010"><td id="1010"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1010">1010</a></td></tr><tr id="gr_svn154_1011"><td id="1011"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1011">1011</a></td></tr><tr id="gr_svn154_1012"><td id="1012"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1012">1012</a></td></tr><tr id="gr_svn154_1013"><td id="1013"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1013">1013</a></td></tr><tr id="gr_svn154_1014"><td id="1014"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1014">1014</a></td></tr><tr id="gr_svn154_1015"><td id="1015"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1015">1015</a></td></tr><tr id="gr_svn154_1016"><td id="1016"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1016">1016</a></td></tr><tr id="gr_svn154_1017"><td id="1017"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1017">1017</a></td></tr><tr id="gr_svn154_1018"><td id="1018"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1018">1018</a></td></tr><tr id="gr_svn154_1019"><td id="1019"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1019">1019</a></td></tr><tr id="gr_svn154_1020"><td id="1020"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1020">1020</a></td></tr><tr id="gr_svn154_1021"><td id="1021"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1021">1021</a></td></tr><tr id="gr_svn154_1022"><td id="1022"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1022">1022</a></td></tr><tr id="gr_svn154_1023"><td id="1023"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1023">1023</a></td></tr><tr id="gr_svn154_1024"><td id="1024"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1024">1024</a></td></tr><tr id="gr_svn154_1025"><td id="1025"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1025">1025</a></td></tr><tr id="gr_svn154_1026"><td id="1026"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1026">1026</a></td></tr><tr id="gr_svn154_1027"><td id="1027"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1027">1027</a></td></tr><tr id="gr_svn154_1028"><td id="1028"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1028">1028</a></td></tr><tr id="gr_svn154_1029"><td id="1029"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1029">1029</a></td></tr><tr id="gr_svn154_1030"><td id="1030"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1030">1030</a></td></tr><tr id="gr_svn154_1031"><td id="1031"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1031">1031</a></td></tr><tr id="gr_svn154_1032"><td id="1032"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1032">1032</a></td></tr><tr id="gr_svn154_1033"><td id="1033"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1033">1033</a></td></tr><tr id="gr_svn154_1034"><td id="1034"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1034">1034</a></td></tr><tr id="gr_svn154_1035"><td id="1035"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1035">1035</a></td></tr><tr id="gr_svn154_1036"><td id="1036"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1036">1036</a></td></tr><tr id="gr_svn154_1037"><td id="1037"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1037">1037</a></td></tr><tr id="gr_svn154_1038"><td id="1038"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1038">1038</a></td></tr><tr id="gr_svn154_1039"><td id="1039"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1039">1039</a></td></tr><tr id="gr_svn154_1040"><td id="1040"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1040">1040</a></td></tr><tr id="gr_svn154_1041"><td id="1041"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1041">1041</a></td></tr><tr id="gr_svn154_1042"><td id="1042"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1042">1042</a></td></tr><tr id="gr_svn154_1043"><td id="1043"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1043">1043</a></td></tr><tr id="gr_svn154_1044"><td id="1044"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1044">1044</a></td></tr><tr id="gr_svn154_1045"><td id="1045"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1045">1045</a></td></tr><tr id="gr_svn154_1046"><td id="1046"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1046">1046</a></td></tr><tr id="gr_svn154_1047"><td id="1047"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1047">1047</a></td></tr><tr id="gr_svn154_1048"><td id="1048"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1048">1048</a></td></tr><tr id="gr_svn154_1049"><td id="1049"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1049">1049</a></td></tr><tr id="gr_svn154_1050"><td id="1050"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1050">1050</a></td></tr><tr id="gr_svn154_1051"><td id="1051"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1051">1051</a></td></tr><tr id="gr_svn154_1052"><td id="1052"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1052">1052</a></td></tr><tr id="gr_svn154_1053"><td id="1053"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1053">1053</a></td></tr><tr id="gr_svn154_1054"><td id="1054"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1054">1054</a></td></tr><tr id="gr_svn154_1055"><td id="1055"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1055">1055</a></td></tr><tr id="gr_svn154_1056"><td id="1056"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1056">1056</a></td></tr><tr id="gr_svn154_1057"><td id="1057"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1057">1057</a></td></tr><tr id="gr_svn154_1058"><td id="1058"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1058">1058</a></td></tr><tr id="gr_svn154_1059"><td id="1059"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1059">1059</a></td></tr><tr id="gr_svn154_1060"><td id="1060"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1060">1060</a></td></tr><tr id="gr_svn154_1061"><td id="1061"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1061">1061</a></td></tr><tr id="gr_svn154_1062"><td id="1062"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1062">1062</a></td></tr><tr id="gr_svn154_1063"><td id="1063"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1063">1063</a></td></tr><tr id="gr_svn154_1064"><td id="1064"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1064">1064</a></td></tr><tr id="gr_svn154_1065"><td id="1065"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1065">1065</a></td></tr><tr id="gr_svn154_1066"><td id="1066"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1066">1066</a></td></tr><tr id="gr_svn154_1067"><td id="1067"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1067">1067</a></td></tr><tr id="gr_svn154_1068"><td id="1068"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1068">1068</a></td></tr><tr id="gr_svn154_1069"><td id="1069"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1069">1069</a></td></tr><tr id="gr_svn154_1070"><td id="1070"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1070">1070</a></td></tr><tr id="gr_svn154_1071"><td id="1071"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1071">1071</a></td></tr><tr id="gr_svn154_1072"><td id="1072"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1072">1072</a></td></tr><tr id="gr_svn154_1073"><td id="1073"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1073">1073</a></td></tr><tr id="gr_svn154_1074"><td id="1074"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1074">1074</a></td></tr><tr id="gr_svn154_1075"><td id="1075"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1075">1075</a></td></tr><tr id="gr_svn154_1076"><td id="1076"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1076">1076</a></td></tr><tr id="gr_svn154_1077"><td id="1077"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1077">1077</a></td></tr><tr id="gr_svn154_1078"><td id="1078"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1078">1078</a></td></tr><tr id="gr_svn154_1079"><td id="1079"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1079">1079</a></td></tr><tr id="gr_svn154_1080"><td id="1080"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1080">1080</a></td></tr><tr id="gr_svn154_1081"><td id="1081"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1081">1081</a></td></tr><tr id="gr_svn154_1082"><td id="1082"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1082">1082</a></td></tr><tr id="gr_svn154_1083"><td id="1083"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1083">1083</a></td></tr><tr id="gr_svn154_1084"><td id="1084"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1084">1084</a></td></tr><tr id="gr_svn154_1085"><td id="1085"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1085">1085</a></td></tr><tr id="gr_svn154_1086"><td id="1086"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1086">1086</a></td></tr><tr id="gr_svn154_1087"><td id="1087"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1087">1087</a></td></tr><tr id="gr_svn154_1088"><td id="1088"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1088">1088</a></td></tr><tr id="gr_svn154_1089"><td id="1089"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1089">1089</a></td></tr><tr id="gr_svn154_1090"><td id="1090"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1090">1090</a></td></tr><tr id="gr_svn154_1091"><td id="1091"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1091">1091</a></td></tr><tr id="gr_svn154_1092"><td id="1092"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1092">1092</a></td></tr><tr id="gr_svn154_1093"><td id="1093"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1093">1093</a></td></tr><tr id="gr_svn154_1094"><td id="1094"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1094">1094</a></td></tr><tr id="gr_svn154_1095"><td id="1095"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1095">1095</a></td></tr><tr id="gr_svn154_1096"><td id="1096"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1096">1096</a></td></tr><tr id="gr_svn154_1097"><td id="1097"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1097">1097</a></td></tr><tr id="gr_svn154_1098"><td id="1098"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1098">1098</a></td></tr><tr id="gr_svn154_1099"><td id="1099"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1099">1099</a></td></tr><tr id="gr_svn154_1100"><td id="1100"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1100">1100</a></td></tr><tr id="gr_svn154_1101"><td id="1101"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1101">1101</a></td></tr><tr id="gr_svn154_1102"><td id="1102"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1102">1102</a></td></tr><tr id="gr_svn154_1103"><td id="1103"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1103">1103</a></td></tr><tr id="gr_svn154_1104"><td id="1104"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1104">1104</a></td></tr><tr id="gr_svn154_1105"><td id="1105"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1105">1105</a></td></tr><tr id="gr_svn154_1106"><td id="1106"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1106">1106</a></td></tr><tr id="gr_svn154_1107"><td id="1107"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1107">1107</a></td></tr><tr id="gr_svn154_1108"><td id="1108"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1108">1108</a></td></tr><tr id="gr_svn154_1109"><td id="1109"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1109">1109</a></td></tr><tr id="gr_svn154_1110"><td id="1110"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1110">1110</a></td></tr><tr id="gr_svn154_1111"><td id="1111"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1111">1111</a></td></tr><tr id="gr_svn154_1112"><td id="1112"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1112">1112</a></td></tr><tr id="gr_svn154_1113"><td id="1113"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1113">1113</a></td></tr><tr id="gr_svn154_1114"><td id="1114"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1114">1114</a></td></tr><tr id="gr_svn154_1115"><td id="1115"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1115">1115</a></td></tr><tr id="gr_svn154_1116"><td id="1116"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1116">1116</a></td></tr><tr id="gr_svn154_1117"><td id="1117"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1117">1117</a></td></tr><tr id="gr_svn154_1118"><td id="1118"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1118">1118</a></td></tr><tr id="gr_svn154_1119"><td id="1119"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1119">1119</a></td></tr><tr id="gr_svn154_1120"><td id="1120"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1120">1120</a></td></tr><tr id="gr_svn154_1121"><td id="1121"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1121">1121</a></td></tr><tr id="gr_svn154_1122"><td id="1122"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1122">1122</a></td></tr><tr id="gr_svn154_1123"><td id="1123"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1123">1123</a></td></tr><tr id="gr_svn154_1124"><td id="1124"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1124">1124</a></td></tr><tr id="gr_svn154_1125"><td id="1125"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1125">1125</a></td></tr><tr id="gr_svn154_1126"><td id="1126"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1126">1126</a></td></tr><tr id="gr_svn154_1127"><td id="1127"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1127">1127</a></td></tr><tr id="gr_svn154_1128"><td id="1128"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1128">1128</a></td></tr><tr id="gr_svn154_1129"><td id="1129"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1129">1129</a></td></tr><tr id="gr_svn154_1130"><td id="1130"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1130">1130</a></td></tr><tr id="gr_svn154_1131"><td id="1131"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1131">1131</a></td></tr><tr id="gr_svn154_1132"><td id="1132"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1132">1132</a></td></tr><tr id="gr_svn154_1133"><td id="1133"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1133">1133</a></td></tr><tr id="gr_svn154_1134"><td id="1134"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1134">1134</a></td></tr><tr id="gr_svn154_1135"><td id="1135"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1135">1135</a></td></tr><tr id="gr_svn154_1136"><td id="1136"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1136">1136</a></td></tr><tr id="gr_svn154_1137"><td id="1137"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1137">1137</a></td></tr><tr id="gr_svn154_1138"><td id="1138"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1138">1138</a></td></tr><tr id="gr_svn154_1139"><td id="1139"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1139">1139</a></td></tr><tr id="gr_svn154_1140"><td id="1140"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1140">1140</a></td></tr><tr id="gr_svn154_1141"><td id="1141"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1141">1141</a></td></tr><tr id="gr_svn154_1142"><td id="1142"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1142">1142</a></td></tr><tr id="gr_svn154_1143"><td id="1143"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1143">1143</a></td></tr><tr id="gr_svn154_1144"><td id="1144"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1144">1144</a></td></tr><tr id="gr_svn154_1145"><td id="1145"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1145">1145</a></td></tr><tr id="gr_svn154_1146"><td id="1146"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1146">1146</a></td></tr><tr id="gr_svn154_1147"><td id="1147"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1147">1147</a></td></tr><tr id="gr_svn154_1148"><td id="1148"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1148">1148</a></td></tr><tr id="gr_svn154_1149"><td id="1149"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1149">1149</a></td></tr><tr id="gr_svn154_1150"><td id="1150"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1150">1150</a></td></tr><tr id="gr_svn154_1151"><td id="1151"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1151">1151</a></td></tr><tr id="gr_svn154_1152"><td id="1152"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1152">1152</a></td></tr><tr id="gr_svn154_1153"><td id="1153"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1153">1153</a></td></tr><tr id="gr_svn154_1154"><td id="1154"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1154">1154</a></td></tr><tr id="gr_svn154_1155"><td id="1155"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1155">1155</a></td></tr><tr id="gr_svn154_1156"><td id="1156"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1156">1156</a></td></tr><tr id="gr_svn154_1157"><td id="1157"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1157">1157</a></td></tr><tr id="gr_svn154_1158"><td id="1158"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1158">1158</a></td></tr><tr id="gr_svn154_1159"><td id="1159"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1159">1159</a></td></tr><tr id="gr_svn154_1160"><td id="1160"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1160">1160</a></td></tr><tr id="gr_svn154_1161"><td id="1161"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1161">1161</a></td></tr><tr id="gr_svn154_1162"><td id="1162"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1162">1162</a></td></tr><tr id="gr_svn154_1163"><td id="1163"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1163">1163</a></td></tr><tr id="gr_svn154_1164"><td id="1164"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1164">1164</a></td></tr><tr id="gr_svn154_1165"><td id="1165"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1165">1165</a></td></tr><tr id="gr_svn154_1166"><td id="1166"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1166">1166</a></td></tr><tr id="gr_svn154_1167"><td id="1167"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1167">1167</a></td></tr><tr id="gr_svn154_1168"><td id="1168"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1168">1168</a></td></tr><tr id="gr_svn154_1169"><td id="1169"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1169">1169</a></td></tr><tr id="gr_svn154_1170"><td id="1170"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1170">1170</a></td></tr><tr id="gr_svn154_1171"><td id="1171"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1171">1171</a></td></tr><tr id="gr_svn154_1172"><td id="1172"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1172">1172</a></td></tr><tr id="gr_svn154_1173"><td id="1173"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1173">1173</a></td></tr><tr id="gr_svn154_1174"><td id="1174"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1174">1174</a></td></tr><tr id="gr_svn154_1175"><td id="1175"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1175">1175</a></td></tr><tr id="gr_svn154_1176"><td id="1176"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1176">1176</a></td></tr><tr id="gr_svn154_1177"><td id="1177"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1177">1177</a></td></tr><tr id="gr_svn154_1178"><td id="1178"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1178">1178</a></td></tr><tr id="gr_svn154_1179"><td id="1179"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1179">1179</a></td></tr><tr id="gr_svn154_1180"><td id="1180"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1180">1180</a></td></tr><tr id="gr_svn154_1181"><td id="1181"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1181">1181</a></td></tr><tr id="gr_svn154_1182"><td id="1182"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1182">1182</a></td></tr><tr id="gr_svn154_1183"><td id="1183"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1183">1183</a></td></tr><tr id="gr_svn154_1184"><td id="1184"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1184">1184</a></td></tr><tr id="gr_svn154_1185"><td id="1185"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1185">1185</a></td></tr><tr id="gr_svn154_1186"><td id="1186"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1186">1186</a></td></tr><tr id="gr_svn154_1187"><td id="1187"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1187">1187</a></td></tr><tr id="gr_svn154_1188"><td id="1188"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1188">1188</a></td></tr><tr id="gr_svn154_1189"><td id="1189"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1189">1189</a></td></tr><tr id="gr_svn154_1190"><td id="1190"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1190">1190</a></td></tr><tr id="gr_svn154_1191"><td id="1191"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1191">1191</a></td></tr><tr id="gr_svn154_1192"><td id="1192"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1192">1192</a></td></tr><tr id="gr_svn154_1193"><td id="1193"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1193">1193</a></td></tr><tr id="gr_svn154_1194"><td id="1194"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1194">1194</a></td></tr><tr id="gr_svn154_1195"><td id="1195"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1195">1195</a></td></tr><tr id="gr_svn154_1196"><td id="1196"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1196">1196</a></td></tr><tr id="gr_svn154_1197"><td id="1197"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1197">1197</a></td></tr><tr id="gr_svn154_1198"><td id="1198"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1198">1198</a></td></tr><tr id="gr_svn154_1199"><td id="1199"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1199">1199</a></td></tr><tr id="gr_svn154_1200"><td id="1200"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1200">1200</a></td></tr><tr id="gr_svn154_1201"><td id="1201"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1201">1201</a></td></tr><tr id="gr_svn154_1202"><td id="1202"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1202">1202</a></td></tr><tr id="gr_svn154_1203"><td id="1203"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1203">1203</a></td></tr><tr id="gr_svn154_1204"><td id="1204"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1204">1204</a></td></tr><tr id="gr_svn154_1205"><td id="1205"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1205">1205</a></td></tr><tr id="gr_svn154_1206"><td id="1206"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1206">1206</a></td></tr><tr id="gr_svn154_1207"><td id="1207"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1207">1207</a></td></tr><tr id="gr_svn154_1208"><td id="1208"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1208">1208</a></td></tr><tr id="gr_svn154_1209"><td id="1209"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1209">1209</a></td></tr><tr id="gr_svn154_1210"><td id="1210"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1210">1210</a></td></tr><tr id="gr_svn154_1211"><td id="1211"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1211">1211</a></td></tr><tr id="gr_svn154_1212"><td id="1212"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1212">1212</a></td></tr><tr id="gr_svn154_1213"><td id="1213"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1213">1213</a></td></tr><tr id="gr_svn154_1214"><td id="1214"><a href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#1214">1214</a></td></tr></tbody></table></pre>
<pre><table width="100%"><tbody><tr class="nocursor"><td></td></tr></tbody></table></pre>
</td>
<td id="lines">
<pre><table width="100%"><tbody><tr class="cursor_stop cursor_hidden"><td></td></tr></tbody></table></pre>
<pre class="prettyprint lang-py"><table id="src_table_0"><tbody><tr id="sl_svn154_1"><td class="source"><span class="com"># Copyright (c) 2007-2009, Mamta Singh. All rights reserved. see README for details.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_2"><td class="source"><span class="com"># Copyright (c) 2010-2011, Kundan Singh.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_3"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_4"><td class="source"><span class="str">'''<br></span></td></tr><tr id="sl_svn154_5"><td class="source"><span class="str">This is a simple implementation of a Flash RTMP server to accept connections and stream requests. The module is organized as follows:<br></span></td></tr><tr id="sl_svn154_6"><td class="source"><span class="str">1. The FlashServer class is the main class to provide the server abstraction. It uses the multitask module for co-operative multitasking.<br></span></td></tr><tr id="sl_svn154_7"><td class="source"><span class="str">&nbsp; &nbsp;It also uses the App abstract class to implement the applications.<br></span></td></tr><tr id="sl_svn154_8"><td class="source"><span class="str">2. The Server class implements a simple server to receive new Client connections and inform the FlashServer application. The Client class<br></span></td></tr><tr id="sl_svn154_9"><td class="source"><span class="str">&nbsp; &nbsp;derived from Protocol implements the RTMP client functions. The Protocol class implements the base RTMP protocol parsing. A Client contains<br></span></td></tr><tr id="sl_svn154_10"><td class="source"><span class="str">&nbsp; &nbsp;various streams from the client, represented using the Stream class.<br></span></td></tr><tr id="sl_svn154_11"><td class="source"><span class="str">3. The Message, Header and Command represent RTMP message, header and command respectively. The FLV class implements functions to perform read<br></span></td></tr><tr id="sl_svn154_12"><td class="source"><span class="str">&nbsp; &nbsp;and write of FLV file format.<br></span></td></tr><tr id="sl_svn154_13"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_14"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_15"><td class="source"><span class="str">Typically an application can launch this server as follows:<br></span></td></tr><tr id="sl_svn154_16"><td class="source"><span class="str">$ python rtmp.py<br></span></td></tr><tr id="sl_svn154_17"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_18"><td class="source"><span class="str">To know the command line options use the -h option:<br></span></td></tr><tr id="sl_svn154_19"><td class="source"><span class="str">$ python rtmp.py -h<br></span></td></tr><tr id="sl_svn154_20"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_21"><td class="source"><span class="str">To start the server with a different directory for recording and playing FLV files from, use the following command.<br></span></td></tr><tr id="sl_svn154_22"><td class="source"><span class="str">$ python rtmp.py -r some-other-directory/<br></span></td></tr><tr id="sl_svn154_23"><td class="source"><span class="str">Note the terminal '/' in the directory name. Without this, it is just used as a prefix in FLV file names.<br></span></td></tr><tr id="sl_svn154_24"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_25"><td class="source"><span class="str">A test client is available in testClient directory, and can be compiled using Flex Builder. Alternatively, you can use the SWF file to launch<br></span></td></tr><tr id="sl_svn154_26"><td class="source"><span class="str">from testClient/bin-debug after starting the server. Once you have launched the client in the browser, you can connect to<br></span></td></tr><tr id="sl_svn154_27"><td class="source"><span class="str">local host by clicking on 'connect' button. Then click on publish button to publish a stream. Open another browser with<br></span></td></tr><tr id="sl_svn154_28"><td class="source"><span class="str">same URL and first connect then play the same stream name. If everything works fine you should be able to see the video<br></span></td></tr><tr id="sl_svn154_29"><td class="source"><span class="str">from first browser to the second browser. Similar, in the first browser, if you check the record box before publishing,<br></span></td></tr><tr id="sl_svn154_30"><td class="source"><span class="str">it will create a new FLV file for the recorded stream. You can close the publishing stream and play the recorded stream to<br></span></td></tr><tr id="sl_svn154_31"><td class="source"><span class="str">see your recording. Note that due to initial delay in timestamp (in case publish was clicked much later than connect),<br></span></td></tr><tr id="sl_svn154_32"><td class="source"><span class="str">your played video will start appearing after some initial delay.<br></span></td></tr><tr id="sl_svn154_33"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_34"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_35"><td class="source"><span class="str">If an application wants to use this module as a library, it can launch the server as follows:<br></span></td></tr><tr id="sl_svn154_36"><td class="source"><span class="str">&gt;&gt;&gt; agent = FlashServer() &nbsp; # a new RTMP server instance<br></span></td></tr><tr id="sl_svn154_37"><td class="source"><span class="str">&gt;&gt;&gt; agent.root = 'flvs/' &nbsp; &nbsp;# set the document root to be 'flvs' directory. Default is current './' directory.<br></span></td></tr><tr id="sl_svn154_38"><td class="source"><span class="str">&gt;&gt;&gt; agent.start() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # start the server<br></span></td></tr><tr id="sl_svn154_39"><td class="source"><span class="str">&gt;&gt;&gt; multitask.run() &nbsp; &nbsp; &nbsp; &nbsp; # this is needed somewhere in the application to actually start the co-operative multitasking.<br></span></td></tr><tr id="sl_svn154_40"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_41"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_42"><td class="source"><span class="str">If an application wants to specify a different application other than the default App, it can subclass it and supply the application by<br></span></td></tr><tr id="sl_svn154_43"><td class="source"><span class="str">setting the server's apps property. The following example shows how to define "myapp" which invokes a 'connected()' method on client when<br></span></td></tr><tr id="sl_svn154_44"><td class="source"><span class="str">the client connects to the server.<br></span></td></tr><tr id="sl_svn154_45"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_46"><td class="source"><span class="str">class MyApp(App): &nbsp; &nbsp; &nbsp; &nbsp; # a new MyApp extends the default App in rtmp module.<br></span></td></tr><tr id="sl_svn154_47"><td class="source"><span class="str">&nbsp; &nbsp; def __init__(self): &nbsp; # constructor just invokes base class constructor<br></span></td></tr><tr id="sl_svn154_48"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; App.__init__(self)<br></span></td></tr><tr id="sl_svn154_49"><td class="source"><span class="str">&nbsp; &nbsp; def onConnect(self, client, *args):<br></span></td></tr><tr id="sl_svn154_50"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; result = App.onConnect(self, client, *args) &nbsp; # invoke base class method first<br></span></td></tr><tr id="sl_svn154_51"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; def invokeAdded(self, client): &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# define a method to invoke 'connected("some-arg")' on Flash client<br></span></td></tr><tr id="sl_svn154_52"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield client.call('connected', 'some-arg')<br></span></td></tr><tr id="sl_svn154_53"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; multitask.add(invokeAdded(self, client)) &nbsp; &nbsp; &nbsp;# need to invoke later so that connection is established before callback<br></span></td></tr><tr id="sl_svn154_54"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; return result &nbsp; &nbsp; # return True to accept, or None to postpone calling accept()<br></span></td></tr><tr id="sl_svn154_55"><td class="source"><span class="str">...<br></span></td></tr><tr id="sl_svn154_56"><td class="source"><span class="str">agent.apps = dict({'myapp': MyApp, 'someapp': MyApp, '*': App})<br></span></td></tr><tr id="sl_svn154_57"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_58"><td class="source"><span class="str">Now the client can connect to rtmp://server/myapp or rtmp://server/someapp and will get connected to this MyApp application.<br></span></td></tr><tr id="sl_svn154_59"><td class="source"><span class="str">If the client doesn't define "function connected(arg:String):void" in the NetConnection.client object then the server will<br></span></td></tr><tr id="sl_svn154_60"><td class="source"><span class="str">throw an exception and display the error message.<br></span></td></tr><tr id="sl_svn154_61"><td class="source"><span class="str"><br></span></td></tr><tr id="sl_svn154_62"><td class="source"><span class="str">'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_63"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_64"><td class="source"><span class="kwd">import</span><span class="pln"> os</span><span class="pun">,</span><span class="pln"> sys</span><span class="pun">,</span><span class="pln"> time</span><span class="pun">,</span><span class="pln"> struct</span><span class="pun">,</span><span class="pln"> socket</span><span class="pun">,</span><span class="pln"> traceback</span><span class="pun">,</span><span class="pln"> multitask</span><span class="pun">,</span><span class="pln"> amf</span><span class="pun">,</span><span class="pln"> hashlib</span><span class="pun">,</span><span class="pln"> hmac</span><span class="pun">,</span><span class="pln"> random<br></span></td></tr><tr id="sl_svn154_65"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_66"><td class="source"><span class="pln">_debug </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">False</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_67"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_68"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">ConnectionClosed</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_69"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'raised when the client closed the connection'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_70"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_71"><td class="source"><span class="kwd">def</span><span class="pln"> truncate</span><span class="pun">(</span><span class="pln">data</span><span class="pun">,</span><span class="pln"> max</span><span class="pun">=</span><span class="lit">100</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_72"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> data </span><span class="kwd">and</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)&gt;</span><span class="pln">max </span><span class="kwd">and</span><span class="pln"> data</span><span class="pun">[:</span><span class="pln">max</span><span class="pun">]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">'...(%d)'</span><span class="pun">%(</span><span class="pln">len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">),)</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> data<br></span></td></tr><tr id="sl_svn154_73"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_74"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">SockStream</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_75"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'''A class that represents a socket as a stream'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_76"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> sock</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_77"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">buffer </span><span class="pun">=</span><span class="pln"> sock</span><span class="pun">,</span><span class="pln"> </span><span class="str">''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_78"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">bytesWritten </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">bytesRead </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_79"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_80"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> close</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_81"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">.</span><span class="pln">close</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_82"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_83"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> read</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> count</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_84"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_85"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> </span><span class="kwd">True</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_86"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">buffer</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&gt;=</span><span class="pln"> count</span><span class="pun">:</span><span class="pln"> </span><span class="com"># do have enough data in buffer</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_87"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">buffer </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">buffer</span><span class="pun">[:</span><span class="pln">count</span><span class="pun">],</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">buffer</span><span class="pun">[</span><span class="pln">count</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_88"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">StopIteration</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_89"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'socket.read[%d] calling recv()'</span><span class="pun">%(</span><span class="pln">count</span><span class="pun">,)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_90"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> multitask</span><span class="pun">.</span><span class="pln">recv</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">,</span><span class="pln"> </span><span class="lit">4096</span><span class="pun">))</span><span class="pln"> </span><span class="com"># read more from socket</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_91"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> data</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ConnectionClosed</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_92"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'socket.read[%d] %r'</span><span class="pun">%(</span><span class="pln">len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">),</span><span class="pln"> truncate</span><span class="pun">(</span><span class="pln">data</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_93"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">bytesRead </span><span class="pun">+=</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_94"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">buffer </span><span class="pun">+=</span><span class="pln"> data<br></span></td></tr><tr id="sl_svn154_95"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">StopIteration</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_96"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ConnectionClosed</span><span class="pln"> </span><span class="com"># anything else is treated as connection closed.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_97"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_98"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> unread</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_99"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">buffer </span><span class="pun">=</span><span class="pln"> data </span><span class="pun">+</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">buffer<br></span></td></tr><tr id="sl_svn154_100"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_101"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> write</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_102"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&gt;</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"> </span><span class="com"># write in 4K chunks each time</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_103"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; chunk</span><span class="pun">,</span><span class="pln"> data </span><span class="pun">=</span><span class="pln"> data</span><span class="pun">[:</span><span class="lit">4096</span><span class="pun">],</span><span class="pln"> data</span><span class="pun">[</span><span class="lit">4096</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_104"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">bytesWritten </span><span class="pun">+=</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">chunk</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_105"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'socket.write[%d] %r'</span><span class="pun">%(</span><span class="pln">len</span><span class="pun">(</span><span class="pln">chunk</span><span class="pun">),</span><span class="pln"> truncate</span><span class="pun">(</span><span class="pln">chunk</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_106"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">yield</span><span class="pln"> multitask</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">,</span><span class="pln"> chunk</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_107"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ConnectionClosed</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_108"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_109"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_110"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_111"><td class="source"><span class="pln">&nbsp; &nbsp; FULL</span><span class="pun">,</span><span class="pln"> MESSAGE</span><span class="pun">,</span><span class="pln"> TIME</span><span class="pun">,</span><span class="pln"> SEPARATOR</span><span class="pun">,</span><span class="pln"> MASK </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0x00</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0x40</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0x80</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0xC0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0xC0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_112"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_113"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> channel</span><span class="pun">=</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> time</span><span class="pun">=</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> size</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> streamId</span><span class="pun">=</span><span class="lit">0</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_114"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">channel</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">streamId </span><span class="pun">=</span><span class="pln"> channel</span><span class="pun">,</span><span class="pln"> time</span><span class="pun">,</span><span class="pln"> size</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">,</span><span class="pln"> streamId<br></span></td></tr><tr id="sl_svn154_115"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> channel</span><span class="pun">&lt;</span><span class="lit">64</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">hdrdata </span><span class="pun">=</span><span class="pln"> chr</span><span class="pun">(</span><span class="pln">channel</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_116"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> channel</span><span class="pun">&lt;(</span><span class="lit">64</span><span class="pun">+</span><span class="lit">256</span><span class="pun">):</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">hdrdata </span><span class="pun">=</span><span class="pln"> </span><span class="str">'\x00'</span><span class="pun">+</span><span class="pln">chr</span><span class="pun">(</span><span class="pln">channel</span><span class="pun">-</span><span class="lit">64</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_117"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">hdrdata </span><span class="pun">=</span><span class="pln"> </span><span class="str">'\x01'</span><span class="pun">+</span><span class="pln">chr</span><span class="pun">((</span><span class="pln">channel</span><span class="pun">-</span><span class="lit">64</span><span class="pun">)%</span><span class="lit">256</span><span class="pun">)+</span><span class="pln">chr</span><span class="pun">((</span><span class="pln">channel</span><span class="pun">-</span><span class="lit">64</span><span class="pun">)/</span><span class="lit">256</span><span class="pun">)</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_118"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_119"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> toBytes</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> control</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_120"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> chr</span><span class="pun">(</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">hdrdata</span><span class="pun">[</span><span class="lit">0</span><span class="pun">])</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> control</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">hdrdata</span><span class="pun">[</span><span class="lit">1</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_121"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> control </span><span class="pun">!=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">SEPARATOR</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_122"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;I'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">time </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">time </span><span class="pun">&lt;</span><span class="pln"> </span><span class="lit">0xFFFFFF</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="lit">0xFFFFFF</span><span class="pun">)[</span><span class="lit">1</span><span class="pun">:]</span><span class="pln"> &nbsp;</span><span class="com"># add time in 3 bytes</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_123"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> control </span><span class="pun">!=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">TIME</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_124"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;I'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">size </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0xFFFFFFFF</span><span class="pun">)[</span><span class="lit">1</span><span class="pun">:]</span><span class="pln"> &nbsp;</span><span class="com"># size</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_125"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> chr</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">type</span><span class="pun">)</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="com"># type</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_126"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> control </span><span class="pun">!=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">MESSAGE</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_127"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&lt;I'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">streamId </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0xFFFFFFFF</span><span class="pun">)</span><span class="pln"> &nbsp;</span><span class="com"># add streamId</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_128"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">time </span><span class="pun">&gt;=</span><span class="pln"> </span><span class="lit">0xFFFFFF</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_129"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;I'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">time </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0xFFFFFFFF</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_130"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> data<br></span></td></tr><tr id="sl_svn154_131"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_132"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __repr__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_133"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">(</span><span class="str">"&lt;Header channel=%r time=%r size=%r type=%s (%r) streamId=%r&gt;"</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_134"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="pun">%</span><span class="pln"> </span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">channel</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">type_name</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> </span><span class="str">'unknown'</span><span class="pun">),</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_135"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_136"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> dup</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_137"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">(</span><span class="pln">channel</span><span class="pun">=</span><span class="pln">self</span><span class="pun">.</span><span class="pln">channel</span><span class="pun">,</span><span class="pln"> time</span><span class="pun">=</span><span class="pln">self</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> size</span><span class="pun">=</span><span class="pln">self</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">=</span><span class="pln">self</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> streamId</span><span class="pun">=</span><span class="pln">self</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_138"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_139"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_140"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_141"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="com"># message types: RPC3, DATA3,and SHAREDOBJECT3 are used with AMF3</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_142"><td class="source"><span class="pln">&nbsp; &nbsp; CHUNK_SIZE</span><span class="pun">,</span><span class="pln"> &nbsp; ABORT</span><span class="pun">,</span><span class="pln"> &nbsp; ACK</span><span class="pun">,</span><span class="pln"> &nbsp; USER_CONTROL</span><span class="pun">,</span><span class="pln"> WIN_ACK_SIZE</span><span class="pun">,</span><span class="pln"> SET_PEER_BW</span><span class="pun">,</span><span class="pln"> AUDIO</span><span class="pun">,</span><span class="pln"> VIDEO</span><span class="pun">,</span><span class="pln"> DATA3</span><span class="pun">,</span><span class="pln"> SHAREDOBJ3</span><span class="pun">,</span><span class="pln"> RPC3</span><span class="pun">,</span><span class="pln"> DATA</span><span class="pun">,</span><span class="pln"> SHAREDOBJ</span><span class="pun">,</span><span class="pln"> RPC </span><span class="pun">=</span><span class="pln"> </span><span class="pun">\</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_143"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="lit">0x01</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="lit">0x02</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp;</span><span class="lit">0x03</span><span class="pun">,</span><span class="pln"> &nbsp;</span><span class="lit">0x04</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="lit">0x05</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="lit">0x06</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="lit">0x08</span><span class="pun">,</span><span class="pln"> &nbsp;</span><span class="lit">0x09</span><span class="pun">,</span><span class="pln"> &nbsp;</span><span class="lit">0x0F</span><span class="pun">,</span><span class="pln"> &nbsp;</span><span class="lit">0x10</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp; </span><span class="lit">0x11</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0x12</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0x13</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp;</span><span class="lit">0x14</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_144"><td class="source"><span class="pln">&nbsp; &nbsp; type_name </span><span class="pun">=</span><span class="pln"> dict</span><span class="pun">(</span><span class="pln">enumerate</span><span class="pun">(</span><span class="str">'unknown chunk-size abort ack user-control win-ack-size set-peer-bw unknown audio video unknown unknown unknown unknown unknown data3 sharedobj3 rpc3 data sharedobj rpc'</span><span class="pun">.</span><span class="pln">split</span><span class="pun">()))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_145"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_146"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> hdr</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">=</span><span class="str">''</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_147"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">header</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">data </span><span class="pun">=</span><span class="pln"> hdr </span><span class="kwd">or</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">(),</span><span class="pln"> data<br></span></td></tr><tr id="sl_svn154_148"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_149"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="com"># define properties type, streamId and time to access self.header.(property)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_150"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">for</span><span class="pln"> p </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">[</span><span class="str">'type'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'streamId'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'time'</span><span class="pun">]:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_151"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">exec</span><span class="pln"> </span><span class="str">'def _g%s(self): return self.header.%s'</span><span class="pun">%(</span><span class="pln">p</span><span class="pun">,</span><span class="pln"> p</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_152"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">exec</span><span class="pln"> </span><span class="str">'def _s%s(self, %s): self.header.%s = %s'</span><span class="pun">%(</span><span class="pln">p</span><span class="pun">,</span><span class="pln"> p</span><span class="pun">,</span><span class="pln"> p</span><span class="pun">,</span><span class="pln"> p</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_153"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">exec</span><span class="pln"> </span><span class="str">'%s = property(fget=_g%s, fset=_s%s)'</span><span class="pun">%(</span><span class="pln">p</span><span class="pun">,</span><span class="pln"> p</span><span class="pun">,</span><span class="pln"> p</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_154"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="lit">@property</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_155"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> size</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"> </span><span class="kwd">return</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_156"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_157"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __repr__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_158"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">(</span><span class="str">"&lt;Message header=%r data=%r&gt;"</span><span class="pun">%</span><span class="pln"> </span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">header</span><span class="pun">,</span><span class="pln"> truncate</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">data</span><span class="pun">)))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_159"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_160"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> dup</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_161"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">header</span><span class="pun">.</span><span class="pln">dup</span><span class="pun">(),</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[:])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_162"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_163"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_164"><td class="source"><span class="pln">&nbsp; &nbsp; PING_SIZE</span><span class="pun">,</span><span class="pln"> DEFAULT_CHUNK_SIZE</span><span class="pun">,</span><span class="pln"> PROTOCOL_CHANNEL_ID </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1536</span><span class="pun">,</span><span class="pln"> </span><span class="lit">128</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="com"># constants</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_165"><td class="source"><span class="pln">&nbsp; &nbsp; READ_WIN_SIZE</span><span class="pun">,</span><span class="pln"> WRITE_WIN_SIZE </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1000000L</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1073741824L</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_166"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_167"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> sock</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_168"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">stream </span><span class="pun">=</span><span class="pln"> </span><span class="typ">SockStream</span><span class="pun">(</span><span class="pln">sock</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_169"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">lastReadHeaders</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">incompletePackets</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">lastWriteHeaders </span><span class="pun">=</span><span class="pln"> dict</span><span class="pun">(),</span><span class="pln"> dict</span><span class="pun">(),</span><span class="pln"> dict</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_170"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">readChunkSize </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeChunkSize </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">DEFAULT_CHUNK_SIZE<br></span></td></tr><tr id="sl_svn154_171"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">readWinSize0</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">readWinSize</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeWinSize0</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeWinSize </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0L</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">READ_WIN_SIZE</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0L</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">WRITE_WIN_SIZE<br></span></td></tr><tr id="sl_svn154_172"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">nextChannelId </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PROTOCOL_CHANNEL_ID </span><span class="pun">+</span><span class="pln"> </span><span class="lit">1</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_173"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">_time0 </span><span class="pun">=</span><span class="pln"> time</span><span class="pun">.</span><span class="pln">time</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_174"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">writeQueue </span><span class="pun">=</span><span class="pln"> multitask</span><span class="pun">.</span><span class="typ">Queue</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_175"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_176"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="lit">@property</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_177"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> relativeTime</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_178"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> int</span><span class="pun">(</span><span class="lit">1000</span><span class="pun">*(</span><span class="pln">time</span><span class="pun">.</span><span class="pln">time</span><span class="pun">()</span><span class="pln"> </span><span class="pun">-</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_time0</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_179"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_180"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> messageReceived</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">):</span><span class="pln"> </span><span class="com"># override in subclass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_181"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_182"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_183"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> protocolMessage</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_184"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">ACK</span><span class="pun">:</span><span class="pln"> </span><span class="com"># respond to ACK requests</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_185"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">writeWinSize0 </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;L'</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">data</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_186"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;response = Message()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_187"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;response.type, response.data = msg.type, msg.data</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_188"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yield self.writeMessage(response)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_189"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">CHUNK_SIZE</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_190"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">readChunkSize </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;L'</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">data</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_191"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">WIN_ACK_SIZE</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_192"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">readWinSize</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">readWinSize0 </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;L'</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">data</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">],</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">bytesRead<br></span></td></tr><tr id="sl_svn154_193"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">USER_CONTROL</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_194"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type</span><span class="pun">,</span><span class="pln"> data </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;H'</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[:</span><span class="lit">2</span><span class="pun">])[</span><span class="lit">0</span><span class="pun">],</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[</span><span class="lit">2</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_195"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> type </span><span class="pun">==</span><span class="pln"> </span><span class="lit">3</span><span class="pun">:</span><span class="pln"> </span><span class="com"># client expects a response when it sends set buffer length</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_196"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; streamId</span><span class="pun">,</span><span class="pln"> bufferTime </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;II'</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_197"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_198"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">data </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">USER_CONTROL</span><span class="pun">,</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;HI'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> streamId</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_199"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">response</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_200"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_201"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_202"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> connectionClosed</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_203"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_204"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_205"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> parse</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_206"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_207"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">parseCrossDomainPolicyRequest</span><span class="pun">()</span><span class="pln"> </span><span class="com"># check for cross domain policy</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_208"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">parseHandshake</span><span class="pun">()</span><span class="pln"> &nbsp;</span><span class="com"># parse rtmp handshake</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_209"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">parseMessages</span><span class="pun">()</span><span class="pln"> &nbsp; </span><span class="com"># parse messages</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_210"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">ConnectionClosed</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_211"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">connectionClosed</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_212"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'parse connection closed'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_213"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_214"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'exception, closing connection'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_215"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> traceback</span><span class="pun">.</span><span class="pln">print_exc</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_216"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">connectionClosed</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_217"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_218"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> writeMessage</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_219"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeQueue</span><span class="pun">.</span><span class="pln">put</span><span class="pun">(</span><span class="pln">message</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_220"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_221"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> parseCrossDomainPolicyRequest</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_222"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># read the request</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_223"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; REQUEST </span><span class="pun">=</span><span class="pln"> </span><span class="str">'&lt;policy-file-request/&gt;\x00'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_224"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="pln">len</span><span class="pun">(</span><span class="pln">REQUEST</span><span class="pun">)))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_225"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> data </span><span class="pun">==</span><span class="pln"> REQUEST</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_226"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> data<br></span></td></tr><tr id="sl_svn154_227"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="str">'''&lt;!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"&gt;<br></span></td></tr><tr id="sl_svn154_228"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cross-domain-policy&gt;<br></span></td></tr><tr id="sl_svn154_229"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;allow-access-from domain="*" to-ports="1935" secure='false'/&gt;<br></span></td></tr><tr id="sl_svn154_230"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/cross-domain-policy&gt;'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_231"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_232"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ConnectionClosed</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_233"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_234"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">unread</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_235"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_236"><td class="source"><span class="pln">&nbsp; &nbsp; SERVER_KEY </span><span class="pun">=</span><span class="pln"> </span><span class="str">'\x47\x65\x6e\x75\x69\x6e\x65\x20\x41\x64\x6f\x62\x65\x20\x46\x6c\x61\x73\x68\x20\x4d\x65\x64\x69\x61\x20\x53\x65\x72\x76\x65\x72\x20\x30\x30\x31\xf0\xee\xc2\x4a\x80\x68\xbe\xe8\x2e\x00\xd0\xd1\x02\x9e\x7e\x57\x6e\xec\x5d\x2d\x29\x80\x6f\xab\x93\xb8\xe6\x36\xcf\xeb\x31\xae'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_237"><td class="source"><span class="pln">&nbsp; &nbsp; FLASHPLAYER_KEY </span><span class="pun">=</span><span class="pln"> </span><span class="str">'\x47\x65\x6E\x75\x69\x6E\x65\x20\x41\x64\x6F\x62\x65\x20\x46\x6C\x61\x73\x68\x20\x50\x6C\x61\x79\x65\x72\x20\x30\x30\x31\xF0\xEE\xC2\x4A\x80\x68\xBE\xE8\x2E\x00\xD0\xD1\x02\x9E\x7E\x57\x6E\xEC\x5D\x2D\x29\x80\x6F\xAB\x93\xB8\xE6\x36\xCF\xEB\x31\xAE'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_238"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_239"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> parseHandshake</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_240"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Parses the rtmp handshake'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_241"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PING_SIZE </span><span class="pun">+</span><span class="pln"> </span><span class="lit">1</span><span class="pun">))</span><span class="pln"> </span><span class="com"># bound version and first ping</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_242"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">handshakeResponse</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_243"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_244"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PING_SIZE</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_245"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_246"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="lit">@staticmethod</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_247"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> handshakeResponse</span><span class="pun">(</span><span class="pln">data</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_248"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># send both data parts before reading next ping-size, to work with ffmpeg</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_249"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;I'</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">[</span><span class="lit">5</span><span class="pun">:</span><span class="lit">9</span><span class="pun">])[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_250"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="str">'\x03'</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">'\x00'</span><span class="pun">*</span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PING_SIZE<br></span></td></tr><tr id="sl_svn154_251"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> data </span><span class="pun">+</span><span class="pln"> data</span><span class="pun">[</span><span class="lit">1</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_252"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_253"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type</span><span class="pun">,</span><span class="pln"> data </span><span class="pun">=</span><span class="pln"> ord</span><span class="pun">(</span><span class="pln">data</span><span class="pun">[</span><span class="lit">0</span><span class="pun">]),</span><span class="pln"> data</span><span class="pun">[</span><span class="lit">1</span><span class="pun">:]</span><span class="pln"> </span><span class="com"># first byte is ignored</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_254"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scheme </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_255"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">for</span><span class="pln"> s </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_256"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; digest_offset </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">data</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">772</span><span class="pun">,</span><span class="pln"> </span><span class="lit">776</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">728</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">776</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> s </span><span class="pun">==</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">data</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">8</span><span class="pun">,</span><span class="pln"> </span><span class="lit">12</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">728</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">12</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_257"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp </span><span class="pun">=</span><span class="pln"> data</span><span class="pun">[</span><span class="lit">0</span><span class="pun">:</span><span class="pln">digest_offset</span><span class="pun">]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> data</span><span class="pun">[</span><span class="pln">digest_offset</span><span class="pun">+</span><span class="lit">32</span><span class="pun">:</span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PING_SIZE</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_258"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hash </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">_calculateHash</span><span class="pun">(</span><span class="pln">temp</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">FLASHPLAYER_KEY</span><span class="pun">[:</span><span class="lit">30</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_259"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hash </span><span class="pun">==</span><span class="pln"> data</span><span class="pun">[</span><span class="pln">digest_offset</span><span class="pun">:</span><span class="pln">digest_offset</span><span class="pun">+</span><span class="lit">32</span><span class="pun">]:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_260"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scheme </span><span class="pun">=</span><span class="pln"> s<br></span></td></tr><tr id="sl_svn154_261"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">break</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_262"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> scheme </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_263"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'invalid RTMP connection data, assuming scheme 0'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_264"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; scheme </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_265"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; client_dh_offset </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">data</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">768</span><span class="pun">,</span><span class="pln"> </span><span class="lit">772</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">632</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">8</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> scheme </span><span class="pun">==</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">data</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">1532</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1536</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">632</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">772</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_266"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; outgoingKp </span><span class="pun">=</span><span class="pln"> data</span><span class="pun">[</span><span class="pln">client_dh_offset</span><span class="pun">:</span><span class="pln">client_dh_offset</span><span class="pun">+</span><span class="lit">128</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_267"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; handshake </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;IBBBB'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="lit">2</span><span class="pun">,</span><span class="pln"> </span><span class="lit">3</span><span class="pun">,</span><span class="pln"> </span><span class="lit">4</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">''</span><span class="pun">.</span><span class="pln">join</span><span class="pun">([</span><span class="pln">chr</span><span class="pun">(</span><span class="pln">random</span><span class="pun">.</span><span class="pln">randint</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">255</span><span class="pun">))</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> xrange</span><span class="pun">(</span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PING_SIZE</span><span class="pun">-</span><span class="lit">8</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_268"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; server_dh_offset </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">handshake</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">768</span><span class="pun">,</span><span class="pln"> </span><span class="lit">772</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">632</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">8</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> scheme </span><span class="pun">==</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">handshake</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">1532</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1536</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">632</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">772</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_269"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; keys </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">_generateKeyPair</span><span class="pun">()</span><span class="pln"> </span><span class="com"># (public, private)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_270"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; handshake </span><span class="pun">=</span><span class="pln"> handshake</span><span class="pun">[:</span><span class="pln">server_dh_offset</span><span class="pun">]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> keys</span><span class="pun">[</span><span class="lit">0</span><span class="pun">][</span><span class="lit">0</span><span class="pun">:</span><span class="lit">128</span><span class="pun">]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> handshake</span><span class="pun">[</span><span class="pln">server_dh_offset</span><span class="pun">+</span><span class="lit">128</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_271"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> type </span><span class="pun">&gt;</span><span class="pln"> </span><span class="lit">0x03</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">Exception</span><span class="pun">(</span><span class="str">'encryption is not supported'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_272"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; server_digest_offset </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">handshake</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">772</span><span class="pun">,</span><span class="pln"> </span><span class="lit">776</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">728</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">776</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> scheme </span><span class="pun">==</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">handshake</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">8</span><span class="pun">,</span><span class="pln"> </span><span class="lit">12</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">728</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">12</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_273"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp </span><span class="pun">=</span><span class="pln"> handshake</span><span class="pun">[</span><span class="lit">0</span><span class="pun">:</span><span class="pln">server_digest_offset</span><span class="pun">]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> handshake</span><span class="pun">[</span><span class="pln">server_digest_offset</span><span class="pun">+</span><span class="lit">32</span><span class="pun">:</span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PING_SIZE</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_274"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hash </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">_calculateHash</span><span class="pun">(</span><span class="pln">temp</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">SERVER_KEY</span><span class="pun">[:</span><span class="lit">36</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_275"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; handshake </span><span class="pun">=</span><span class="pln"> handshake</span><span class="pun">[:</span><span class="pln">server_digest_offset</span><span class="pun">]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> hash </span><span class="pun">+</span><span class="pln"> handshake</span><span class="pun">[</span><span class="pln">server_digest_offset</span><span class="pun">+</span><span class="lit">32</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_276"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buffer </span><span class="pun">=</span><span class="pln"> data</span><span class="pun">[:</span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PING_SIZE</span><span class="pun">-</span><span class="lit">32</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_277"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; key_challenge_offset </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">buffer</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">772</span><span class="pun">,</span><span class="pln"> </span><span class="lit">776</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">728</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">776</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> scheme </span><span class="pun">==</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sum</span><span class="pun">([</span><span class="pln">ord</span><span class="pun">(</span><span class="pln">buffer</span><span class="pun">[</span><span class="pln">i</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">8</span><span class="pun">,</span><span class="pln"> </span><span class="lit">12</span><span class="pun">)])</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="lit">728</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">12</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_278"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; challenge_key </span><span class="pun">=</span><span class="pln"> data</span><span class="pun">[</span><span class="pln">key_challenge_offset</span><span class="pun">:</span><span class="pln">key_challenge_offset</span><span class="pun">+</span><span class="lit">32</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_279"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hash </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">_calculateHash</span><span class="pun">(</span><span class="pln">challenge_key</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">SERVER_KEY</span><span class="pun">[:</span><span class="lit">68</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_280"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rand_bytes </span><span class="pun">=</span><span class="pln"> </span><span class="str">''</span><span class="pun">.</span><span class="pln">join</span><span class="pun">([</span><span class="pln">chr</span><span class="pun">(</span><span class="pln">random</span><span class="pun">.</span><span class="pln">randint</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">255</span><span class="pun">))</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> xrange</span><span class="pun">(</span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PING_SIZE</span><span class="pun">-</span><span class="lit">32</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_281"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; last_hash </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">_calculateHash</span><span class="pun">(</span><span class="pln">rand_bytes</span><span class="pun">,</span><span class="pln"> hash</span><span class="pun">[:</span><span class="lit">32</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_282"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; output </span><span class="pun">=</span><span class="pln"> chr</span><span class="pun">(</span><span class="pln">type</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> handshake </span><span class="pun">+</span><span class="pln"> rand_bytes </span><span class="pun">+</span><span class="pln"> last_hash<br></span></td></tr><tr id="sl_svn154_283"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> output<br></span></td></tr><tr id="sl_svn154_284"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_285"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="lit">@staticmethod</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_286"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> _calculateHash</span><span class="pun">(</span><span class="pln">msg</span><span class="pun">,</span><span class="pln"> key</span><span class="pun">):</span><span class="pln"> </span><span class="com"># Hmac-sha256</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_287"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> hmac</span><span class="pun">.</span><span class="pln">new</span><span class="pun">(</span><span class="pln">key</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">,</span><span class="pln"> hashlib</span><span class="pun">.</span><span class="pln">sha256</span><span class="pun">).</span><span class="pln">digest</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_288"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_289"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="lit">@staticmethod</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_290"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> _generateKeyPair</span><span class="pun">():</span><span class="pln"> </span><span class="com"># dummy key pair since we don't support encryption</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_291"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">(</span><span class="str">''</span><span class="pun">.</span><span class="pln">join</span><span class="pun">([</span><span class="pln">chr</span><span class="pun">(</span><span class="pln">random</span><span class="pun">.</span><span class="pln">randint</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">255</span><span class="pun">))</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> i </span><span class="kwd">in</span><span class="pln"> xrange</span><span class="pun">(</span><span class="lit">128</span><span class="pun">)]),</span><span class="pln"> </span><span class="str">''</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_292"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_293"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> parseMessages</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_294"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Parses complete messages until connection closed. Raises ConnectionLost exception.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_295"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; CHANNEL_MASK </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0x3F</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_296"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> </span><span class="kwd">True</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_297"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hdrsize </span><span class="pun">=</span><span class="pln"> ord</span><span class="pun">((</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">1</span><span class="pun">))[</span><span class="lit">0</span><span class="pun">])</span><span class="pln"> &nbsp;</span><span class="com"># read header size byte</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_298"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; channel </span><span class="pun">=</span><span class="pln"> hdrsize </span><span class="pun">&amp;</span><span class="pln"> CHANNEL_MASK<br></span></td></tr><tr id="sl_svn154_299"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> channel </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"> </span><span class="com"># we need one more byte</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_300"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; channel </span><span class="pun">=</span><span class="pln"> </span><span class="lit">64</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> ord</span><span class="pun">((</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">1</span><span class="pun">))[</span><span class="lit">0</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_301"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> channel </span><span class="pun">==</span><span class="pln"> </span><span class="lit">1</span><span class="pun">:</span><span class="pln"> </span><span class="com"># we need two more bytes</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_302"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">2</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_303"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; channel </span><span class="pun">=</span><span class="pln"> </span><span class="lit">64</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> ord</span><span class="pun">(</span><span class="pln">data</span><span class="pun">[</span><span class="lit">0</span><span class="pun">])</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="lit">256</span><span class="pln"> </span><span class="pun">*</span><span class="pln"> ord</span><span class="pun">(</span><span class="pln">data</span><span class="pun">[</span><span class="lit">1</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_304"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_305"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hdrtype </span><span class="pun">=</span><span class="pln"> hdrsize </span><span class="pun">&amp;</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">MASK &nbsp; </span><span class="com"># read header type byte</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_306"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hdrtype </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">FULL </span><span class="kwd">or</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">lastReadHeaders</span><span class="pun">.</span><span class="pln">has_key</span><span class="pun">(</span><span class="pln">channel</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_307"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">(</span><span class="pln">channel</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_308"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">lastReadHeaders</span><span class="pun">[</span><span class="pln">channel</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> header<br></span></td></tr><tr id="sl_svn154_309"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_310"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">lastReadHeaders</span><span class="pun">[</span><span class="pln">channel</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_311"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_312"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hdrtype </span><span class="pun">&lt;</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">SEPARATOR</span><span class="pun">:</span><span class="pln"> </span><span class="com"># time or delta has changed</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_313"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">3</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_314"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">time </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'!I'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'\x00'</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> data</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_315"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_316"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hdrtype </span><span class="pun">&lt;</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">TIME</span><span class="pun">:</span><span class="pln"> </span><span class="com"># size and type also changed</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_317"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">3</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_318"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">size </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'!I'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'\x00'</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> data</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_319"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> ord</span><span class="pun">((</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">1</span><span class="pun">))[</span><span class="lit">0</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_320"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_321"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hdrtype </span><span class="pun">&lt;</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">MESSAGE</span><span class="pun">:</span><span class="pln"> </span><span class="com"># streamId also changed</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_322"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">4</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_323"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">streamId </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&lt;I'</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_324"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_325"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">time </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0xFFFFFF</span><span class="pun">:</span><span class="pln"> </span><span class="com"># if we have extended timestamp, read it</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_326"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">4</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_327"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">extendedTime </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'!I'</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_328"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'extended time stamp'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'%x'</span><span class="pun">%(</span><span class="pln">header</span><span class="pun">.</span><span class="pln">extendedTime</span><span class="pun">,)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_329"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_330"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">extendedTime </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_331"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_332"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hdrtype </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">FULL</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_333"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">currentTime </span><span class="pun">=</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">extendedTime </span><span class="kwd">or</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">time<br></span></td></tr><tr id="sl_svn154_334"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">hdrtype </span><span class="pun">=</span><span class="pln"> hdrtype<br></span></td></tr><tr id="sl_svn154_335"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> hdrtype </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">(</span><span class="typ">Header</span><span class="pun">.</span><span class="pln">MESSAGE</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">TIME</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_336"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">hdrtype </span><span class="pun">=</span><span class="pln"> hdrtype<br></span></td></tr><tr id="sl_svn154_337"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_338"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com">#print header.type, '0x%02x'%(hdrtype,), header.time, header.currentTime</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_339"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_340"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if _debug: print 'R', header, header.currentTime, header.extendedTime, '0x%x'%(hdrsize,)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_341"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br></span></td></tr><tr id="sl_svn154_342"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">incompletePackets</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(</span><span class="pln">channel</span><span class="pun">,</span><span class="pln"> </span><span class="str">""</span><span class="pun">)</span><span class="pln"> </span><span class="com"># are we continuing an incomplete packet?</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_343"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_344"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count </span><span class="pun">=</span><span class="pln"> min</span><span class="pun">(</span><span class="pln">header</span><span class="pun">.</span><span class="pln">size </span><span class="pun">-</span><span class="pln"> </span><span class="pun">(</span><span class="pln">len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)),</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">readChunkSize</span><span class="pun">)</span><span class="pln"> </span><span class="com"># how much more</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_345"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_346"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="pln">count</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_347"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_348"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># check if we need to send Ack</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_349"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">readWinSize </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_350"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">bytesRead </span><span class="pun">&gt;</span><span class="pln"> </span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">readWinSize0 </span><span class="pun">+</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">readWinSize</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_351"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">readWinSize0 </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">bytesRead<br></span></td></tr><tr id="sl_svn154_352"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ack </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_353"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ack</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> ack</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> ack</span><span class="pun">.</span><span class="pln">data </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">ACK</span><span class="pun">,</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;L'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">readWinSize0</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_354"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">ack</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_355"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_356"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&lt;</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">size</span><span class="pun">:</span><span class="pln"> </span><span class="com"># we don't have all data</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_357"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">incompletePackets</span><span class="pun">[</span><span class="pln">channel</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> data<br></span></td></tr><tr id="sl_svn154_358"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"> </span><span class="com"># we have all data</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_359"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hdrtype </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">(</span><span class="typ">Header</span><span class="pun">.</span><span class="pln">MESSAGE</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">TIME</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_360"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">currentTime </span><span class="pun">=</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">currentTime </span><span class="pun">+</span><span class="pln"> </span><span class="pun">(</span><span class="pln">header</span><span class="pun">.</span><span class="pln">extendedTime </span><span class="kwd">or</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">time</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_361"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> hdrtype </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">SEPARATOR</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_362"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">hdrtype </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">(</span><span class="typ">Header</span><span class="pun">.</span><span class="pln">MESSAGE</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">TIME</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_363"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">currentTime </span><span class="pun">=</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">currentTime </span><span class="pun">+</span><span class="pln"> </span><span class="pun">(</span><span class="pln">header</span><span class="pun">.</span><span class="pln">extendedTime </span><span class="kwd">or</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">time</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_364"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">size</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_365"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> channel </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">incompletePackets</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_366"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">del</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">incompletePackets</span><span class="pun">[</span><span class="pln">channel</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_367"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_368"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">incompletePackets</span><span class="pun">[</span><span class="pln">channel</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> data</span><span class="pun">[:</span><span class="pln">header</span><span class="pun">.</span><span class="pln">size</span><span class="pun">],</span><span class="pln"> data</span><span class="pun">[</span><span class="pln">header</span><span class="pun">.</span><span class="pln">size</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_369"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_370"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hdr </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">(</span><span class="pln">channel</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">channel</span><span class="pun">,</span><span class="pln"> time</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">currentTime</span><span class="pun">,</span><span class="pln"> size</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> streamId</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_371"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">(</span><span class="pln">hdr</span><span class="pun">,</span><span class="pln"> data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_372"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'Protocol.parseMessage msg='</span><span class="pun">,</span><span class="pln"> msg<br></span></td></tr><tr id="sl_svn154_373"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_374"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> channel </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PROTOCOL_CHANNEL_ID</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_375"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">protocolMessage</span><span class="pun">(</span><span class="pln">msg</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_376"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_377"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">messageReceived</span><span class="pun">(</span><span class="pln">msg</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_378"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_379"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'Protocol.parseMessages exception'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">traceback </span><span class="kwd">and</span><span class="pln"> traceback</span><span class="pun">.</span><span class="pln">print_exc</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_380"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_381"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> write</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_382"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Writes messages to stream'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_383"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> </span><span class="kwd">True</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_384"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;while self.writeQueue.empty(): (yield multitask.sleep(0.01))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_385"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;message = self.writeQueue.get() # TODO this should be used using multitask.Queue and remove previous wait.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_386"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeQueue</span><span class="pun">.</span><span class="pln">get</span><span class="pun">()</span><span class="pln"> </span><span class="com"># TODO this should be used using multitask.Queue and remove previous wait.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_387"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'Protocol.write msg='</span><span class="pun">,</span><span class="pln"> message<br></span></td></tr><tr id="sl_svn154_388"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_389"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">close</span><span class="pun">()</span><span class="pln"> &nbsp;</span><span class="com"># just in case TCP socket is not closed, close it.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_390"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_391"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">break</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_392"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_393"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># get the header stored for the stream</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_394"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">lastWriteHeaders</span><span class="pun">.</span><span class="pln">has_key</span><span class="pun">(</span><span class="pln">message</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_395"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">lastWriteHeaders</span><span class="pun">[</span><span class="pln">message</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_396"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_397"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">nextChannelId </span><span class="pun">&lt;=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PROTOCOL_CHANNEL_ID</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">nextChannelId </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PROTOCOL_CHANNEL_ID</span><span class="pun">+</span><span class="lit">1</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_398"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">nextChannelId </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">nextChannelId</span><span class="pun">),</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">nextChannelId </span><span class="pun">+</span><span class="pln"> </span><span class="lit">1</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_399"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">lastWriteHeaders</span><span class="pun">[</span><span class="pln">message</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> header<br></span></td></tr><tr id="sl_svn154_400"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">&lt;</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">AUDIO</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_401"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">(</span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">PROTOCOL_CHANNEL_ID</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_402"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br></span></td></tr><tr id="sl_svn154_403"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># now figure out the header data bytes</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_404"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">streamId </span><span class="pun">!=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">streamId </span><span class="kwd">or</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">time </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">time </span><span class="pun">&lt;=</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">time</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_405"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">,</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">delta </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">time<br></span></td></tr><tr id="sl_svn154_406"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; control </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">FULL<br></span></td></tr><tr id="sl_svn154_407"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">size </span><span class="pun">!=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">size </span><span class="kwd">or</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">type </span><span class="pun">!=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_408"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">delta </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">time</span><span class="pun">-</span><span class="pln">header</span><span class="pun">.</span><span class="pln">time<br></span></td></tr><tr id="sl_svn154_409"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; control </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">MESSAGE<br></span></td></tr><tr id="sl_svn154_410"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_411"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; header</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">delta </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">time</span><span class="pun">-</span><span class="pln">header</span><span class="pun">.</span><span class="pln">time<br></span></td></tr><tr id="sl_svn154_412"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; control </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">TIME<br></span></td></tr><tr id="sl_svn154_413"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_414"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hdr </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">(</span><span class="pln">channel</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">channel</span><span class="pun">,</span><span class="pln"> time</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">delta </span><span class="kwd">if</span><span class="pln"> control </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">(</span><span class="typ">Header</span><span class="pun">.</span><span class="pln">MESSAGE</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">TIME</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> header</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> size</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> streamId</span><span class="pun">=</span><span class="pln">header</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_415"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">assert</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">size </span><span class="pun">==</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_416"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_417"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="str">''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_418"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&gt;</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_419"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> hdr</span><span class="pun">.</span><span class="pln">toBytes</span><span class="pun">(</span><span class="pln">control</span><span class="pun">)</span><span class="pln"> </span><span class="com"># gather header bytes</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_420"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; count </span><span class="pun">=</span><span class="pln"> min</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">writeChunkSize</span><span class="pun">,</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_421"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[:</span><span class="pln">count</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_422"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; message</span><span class="pun">.</span><span class="pln">data </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[</span><span class="pln">count</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_423"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; control </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">.</span><span class="pln">SEPARATOR </span><span class="com"># incomplete message continuation</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_424"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_425"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_426"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">ConnectionClosed</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_427"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">connectionClosed</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_428"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_429"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">print</span><span class="pln"> traceback</span><span class="pun">.</span><span class="pln">print_exc</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_430"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_431"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_432"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">''' Class for command / data messages'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_433"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">=</span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC</span><span class="pun">,</span><span class="pln"> name</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">=</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> cmdData</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">=[]):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_434"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Create a new command with given type, name, id, cmdData and args list.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_435"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">cmdData</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">args </span><span class="pun">=</span><span class="pln"> type</span><span class="pun">,</span><span class="pln"> name</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">,</span><span class="pln"> cmdData</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">[:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_436"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_437"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __repr__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_438"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="pun">(</span><span class="str">"&lt;Command type=%r name=%r id=%r data=%r args=%r&gt;"</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">cmdData</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">args</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_439"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_440"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> setArg</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> arg</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_441"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">args</span><span class="pun">.</span><span class="pln">append</span><span class="pun">(</span><span class="pln">arg</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_442"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_443"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> getArg</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> index</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_444"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">args</span><span class="pun">[</span><span class="pln">index</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_445"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_446"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="lit">@classmethod</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_447"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> fromMessage</span><span class="pun">(</span><span class="pln">cls</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_448"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">''' initialize from a parsed RTMP message'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_449"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">assert</span><span class="pln"> </span><span class="pun">(</span><span class="pln">message</span><span class="pun">.</span><span class="pln">type </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">[</span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC3</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">DATA</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">DATA3</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_450"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_451"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; length </span><span class="pun">=</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_452"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> length </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">(</span><span class="str">'zero length message data'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_453"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_454"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC3 </span><span class="kwd">or</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">DATA3</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_455"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">assert</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="str">'\x00'</span><span class="pln"> </span><span class="com"># must be 0 in AMF3</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_456"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[</span><span class="lit">1</span><span class="pun">:]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_457"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_458"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">data<br></span></td></tr><tr id="sl_svn154_459"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_460"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; amfReader </span><span class="pun">=</span><span class="pln"> amf</span><span class="pun">.</span><span class="pln">AMF0</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_461"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_462"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; inst </span><span class="pun">=</span><span class="pln"> cls</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_463"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type<br></span></td></tr><tr id="sl_svn154_464"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">time </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">time<br></span></td></tr><tr id="sl_svn154_465"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">name </span><span class="pun">=</span><span class="pln"> amfReader</span><span class="pun">.</span><span class="pln">read</span><span class="pun">()</span><span class="pln"> </span><span class="com"># first field is command name</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_466"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_467"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_468"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC </span><span class="kwd">or</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC3</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_469"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">id </span><span class="pun">=</span><span class="pln"> amfReader</span><span class="pun">.</span><span class="pln">read</span><span class="pun">()</span><span class="pln"> </span><span class="com"># second field *may* be message id</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_470"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">cmdData </span><span class="pun">=</span><span class="pln"> amfReader</span><span class="pun">.</span><span class="pln">read</span><span class="pun">()</span><span class="pln"> </span><span class="com"># third is command data</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_471"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_472"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">id </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_473"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">args </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[]</span><span class="pln"> </span><span class="com"># others are optional</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_474"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> </span><span class="kwd">True</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_475"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">args</span><span class="pun">.</span><span class="pln">append</span><span class="pun">(</span><span class="pln">amfReader</span><span class="pun">.</span><span class="pln">read</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_476"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">EOFError</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_477"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_478"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> inst<br></span></td></tr><tr id="sl_svn154_479"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_480"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> toMessage</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_481"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; msg </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_482"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">assert</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">type<br></span></td></tr><tr id="sl_svn154_483"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">type<br></span></td></tr><tr id="sl_svn154_484"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; msg</span><span class="pun">.</span><span class="pln">time </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">time<br></span></td></tr><tr id="sl_svn154_485"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; output </span><span class="pun">=</span><span class="pln"> amf</span><span class="pun">.</span><span class="typ">BytesIO</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_486"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; amfWriter </span><span class="pun">=</span><span class="pln"> amf</span><span class="pun">.</span><span class="pln">AMF0</span><span class="pun">(</span><span class="pln">output</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_487"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; amfWriter</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_488"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC </span><span class="kwd">or</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC3</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_489"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; amfWriter</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">id</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_490"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; amfWriter</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">cmdData</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_491"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">for</span><span class="pln"> arg </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">args</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_492"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; amfWriter</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">arg</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_493"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; output</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="lit">0</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_494"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com">#hexdump.hexdump(output)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_495"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com">#output.seek(0)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_496"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC3 </span><span class="kwd">or</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">DATA3</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_497"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> </span><span class="str">'\x00'</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> output</span><span class="pun">.</span><span class="pln">read</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_498"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_499"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> output</span><span class="pun">.</span><span class="pln">read</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_500"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; msg</span><span class="pun">.</span><span class="pln">data </span><span class="pun">=</span><span class="pln"> data<br></span></td></tr><tr id="sl_svn154_501"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; output</span><span class="pun">.</span><span class="pln">close</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_502"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> msg<br></span></td></tr><tr id="sl_svn154_503"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_504"><td class="source"><span class="kwd">def</span><span class="pln"> getfilename</span><span class="pun">(</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> name</span><span class="pun">,</span><span class="pln"> root</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_505"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'''return the file name for the given stream. The name is derived as root/scope/name.flv where scope is<br></span></td></tr><tr id="sl_svn154_506"><td class="source"><span class="str">&nbsp; &nbsp; the the path present in the path variable.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_507"><td class="source"><span class="pln">&nbsp; &nbsp; ignore</span><span class="pun">,</span><span class="pln"> ignore</span><span class="pun">,</span><span class="pln"> scope </span><span class="pun">=</span><span class="pln"> path</span><span class="pun">.</span><span class="pln">partition</span><span class="pun">(</span><span class="str">'/'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_508"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> scope</span><span class="pun">:</span><span class="pln"> scope </span><span class="pun">=</span><span class="pln"> scope </span><span class="pun">+</span><span class="pln"> </span><span class="str">'/'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_509"><td class="source"><span class="pln">&nbsp; &nbsp; result </span><span class="pun">=</span><span class="pln"> root </span><span class="pun">+</span><span class="pln"> scope </span><span class="pun">+</span><span class="pln"> name </span><span class="pun">+</span><span class="pln"> </span><span class="str">'.flv'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_510"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'filename='</span><span class="pun">,</span><span class="pln"> result<br></span></td></tr><tr id="sl_svn154_511"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> result<br></span></td></tr><tr id="sl_svn154_512"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_513"><td class="source"><span class="kwd">class</span><span class="pln"> FLV</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_514"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'''An FLV file which converts between RTMP message and FLV tags.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_515"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_516"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fname </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_517"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">tsp </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsr </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsr0 </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_518"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_519"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> open</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> path</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">=</span><span class="str">'read'</span><span class="pun">,</span><span class="pln"> mode</span><span class="pun">=</span><span class="lit">0775</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_520"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Open the file for reading (type=read) or writing (type=record or append).'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_521"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">path</span><span class="pun">).</span><span class="pln">find</span><span class="pun">(</span><span class="str">'/../'</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&gt;=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">path</span><span class="pun">).</span><span class="pln">find</span><span class="pun">(</span><span class="str">'\\..\\'</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&gt;=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">(</span><span class="str">'Must not contain .. in name'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_522"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'opening file'</span><span class="pun">,</span><span class="pln"> path<br></span></td></tr><tr id="sl_svn154_523"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">tsp </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsr </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsr0 </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">;</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> type<br></span></td></tr><tr id="sl_svn154_524"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> type </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">(</span><span class="str">'record'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'append'</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_525"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">makedirs</span><span class="pun">(</span><span class="pln">os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">dirname</span><span class="pun">(</span><span class="pln">path</span><span class="pun">),</span><span class="pln"> mode</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_526"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_527"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp </span><span class="pun">=</span><span class="pln"> open</span><span class="pun">(</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="str">'w'</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> type </span><span class="pun">==</span><span class="pln"> </span><span class="str">'record'</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="str">'a'</span><span class="pun">)+</span><span class="str">'b'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_528"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> type </span><span class="pun">==</span><span class="pln"> </span><span class="str">'record'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_529"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="str">'FLV\x01\x05\x00\x00\x00\x09\x00\x00\x00\x00'</span><span class="pun">)</span><span class="pln"> </span><span class="com"># the header and first previousTagSize</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_530"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">writeDuration</span><span class="pun">(</span><span class="lit">0.0</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_531"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_532"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp </span><span class="pun">=</span><span class="pln"> open</span><span class="pun">(</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> </span><span class="str">'rb'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_533"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; magic</span><span class="pun">,</span><span class="pln"> version</span><span class="pun">,</span><span class="pln"> flags</span><span class="pun">,</span><span class="pln"> offset </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'!3sBBI'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">9</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_534"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'FLV.open() hdr='</span><span class="pun">,</span><span class="pln"> magic</span><span class="pun">,</span><span class="pln"> version</span><span class="pun">,</span><span class="pln"> flags</span><span class="pun">,</span><span class="pln"> offset<br></span></td></tr><tr id="sl_svn154_535"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> magic </span><span class="pun">!=</span><span class="pln"> </span><span class="str">'FLV'</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">(</span><span class="str">'This is not a FLV file'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_536"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> version </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">(</span><span class="str">'Unsupported FLV file version'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_537"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> offset </span><span class="pun">&gt;</span><span class="pln"> </span><span class="lit">9</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="pln">offset</span><span class="pun">-</span><span class="lit">9</span><span class="pun">,</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">SEEK_CUR</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_538"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">4</span><span class="pun">)</span><span class="pln"> </span><span class="com"># ignore first previous tag size</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_539"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> self <br></span></td></tr><tr id="sl_svn154_540"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_541"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> close</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_542"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Close the underlying file for this object.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_543"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'closing flv file'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_544"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="str">'record'</span><span class="pln"> </span><span class="kwd">and</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsr0 </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeDuration</span><span class="pun">((</span><span class="pln">self</span><span class="pun">.</span><span class="pln">tsr </span><span class="pun">-</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsr0</span><span class="pun">)/</span><span class="lit">1000.0</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_545"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_546"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">close</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_547"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_548"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_549"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_550"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> delete</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> path</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_551"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Delete the underlying file for this object.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_552"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">unlink</span><span class="pun">(</span><span class="pln">path</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_553"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_554"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_555"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> writeDuration</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> duration</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_556"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'writing duration'</span><span class="pun">,</span><span class="pln"> duration<br></span></td></tr><tr id="sl_svn154_557"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; output </span><span class="pun">=</span><span class="pln"> amf</span><span class="pun">.</span><span class="typ">BytesIO</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_558"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; amfWriter </span><span class="pun">=</span><span class="pln"> amf</span><span class="pun">.</span><span class="pln">AMF0</span><span class="pun">(</span><span class="pln">output</span><span class="pun">)</span><span class="pln"> </span><span class="com"># TODO: use AMF3 if needed</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_559"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; amfWriter</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="str">'onMetaData'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_560"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; amfWriter</span><span class="pun">.</span><span class="pln">write</span><span class="pun">({</span><span class="str">"duration"</span><span class="pun">:</span><span class="pln"> duration</span><span class="pun">,</span><span class="pln"> </span><span class="str">"videocodecid"</span><span class="pun">:</span><span class="pln"> </span><span class="lit">2</span><span class="pun">})</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_561"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; output</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="lit">0</span><span class="pun">);</span><span class="pln"> data </span><span class="pun">=</span><span class="pln"> output</span><span class="pun">.</span><span class="pln">read</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_562"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; length</span><span class="pun">,</span><span class="pln"> ts </span><span class="pun">=</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">),</span><span class="pln"> </span><span class="lit">0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_563"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;BBHBHB'</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">DATA</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">length </span><span class="pun">&gt;&gt;</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0xff</span><span class="pun">,</span><span class="pln"> length </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0x0ffff</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts </span><span class="pun">&gt;&gt;</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0xff</span><span class="pun">,</span><span class="pln"> ts </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0x0ffff</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts </span><span class="pun">&gt;&gt;</span><span class="pln"> </span><span class="lit">24</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0xff</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">'\x00\x00\x00'</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> &nbsp;data<br></span></td></tr><tr id="sl_svn154_564"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;I'</span><span class="pun">,</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_565"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; lastpos </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">tell</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_566"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> lastpos </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">13</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="lit">13</span><span class="pun">,</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">SEEK_SET</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_567"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_568"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> lastpos </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">13</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="pln">lastpos</span><span class="pun">,</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">SEEK_SET</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_569"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_570"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> write</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_571"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Write a message to the file, assuming it was opened for writing or appending.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_572"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp;if message.type == Message.VIDEO:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_573"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.videostarted = True</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_574"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp;elif not hasattr(self, "videostarted"): return</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_575"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">AUDIO </span><span class="kwd">or</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">VIDEO</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_576"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length</span><span class="pun">,</span><span class="pln"> ts </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">size</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">time<br></span></td></tr><tr id="sl_svn154_577"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com">#if _debug: print 'FLV.write()', message.type, ts</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_578"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsr0 </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsr0 </span><span class="pun">=</span><span class="pln"> ts<br></span></td></tr><tr id="sl_svn154_579"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">tsr</span><span class="pun">,</span><span class="pln"> ts </span><span class="pun">=</span><span class="pln"> ts</span><span class="pun">,</span><span class="pln"> ts </span><span class="pun">-</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsr0<br></span></td></tr><tr id="sl_svn154_580"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if message.type == Message.AUDIO: print 'w', message.type, ts</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_581"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;BBHBHB'</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">length </span><span class="pun">&gt;&gt;</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0xff</span><span class="pun">,</span><span class="pln"> length </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0x0ffff</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts </span><span class="pun">&gt;&gt;</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0xff</span><span class="pun">,</span><span class="pln"> ts </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0x0ffff</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts </span><span class="pun">&gt;&gt;</span><span class="pln"> </span><span class="lit">24</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0xff</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">'\x00\x00\x00'</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> &nbsp;message</span><span class="pun">.</span><span class="pln">data<br></span></td></tr><tr id="sl_svn154_582"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data </span><span class="pun">+=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;I'</span><span class="pun">,</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">data</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_583"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">data</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_584"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_585"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> reader</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_586"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''A generator to periodically read the file and dispatch them to the stream. The supplied stream<br></span></td></tr><tr id="sl_svn154_587"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; object must have a send(Message) method and id and client properties.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_588"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'reader started'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_589"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_590"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_591"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_592"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bytes </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">11</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_593"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">bytes</span><span class="pun">)</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_594"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">'onStatus'</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">=[</span><span class="pln">amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'status'</span><span class="pun">,</span><span class="pln">code</span><span class="pun">=</span><span class="str">'NetStream.Play.Stop'</span><span class="pun">,</span><span class="pln"> description</span><span class="pun">=</span><span class="str">'File ended'</span><span class="pun">,</span><span class="pln"> details</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_595"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_596"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">break</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_597"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type</span><span class="pun">,</span><span class="pln"> len0</span><span class="pun">,</span><span class="pln"> len1</span><span class="pun">,</span><span class="pln"> ts0</span><span class="pun">,</span><span class="pln"> ts1</span><span class="pun">,</span><span class="pln"> ts2</span><span class="pun">,</span><span class="pln"> sid0</span><span class="pun">,</span><span class="pln"> sid1 </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;BBHBHBBH'</span><span class="pun">,</span><span class="pln"> bytes</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_598"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">len0 </span><span class="pun">&lt;&lt;</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> len1</span><span class="pun">;</span><span class="pln"> ts </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts0 </span><span class="pun">&lt;&lt;</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts1 </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0x0ffff</span><span class="pun">)</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts2 </span><span class="pun">&lt;&lt;</span><span class="pln"> </span><span class="lit">24</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_599"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; body </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="pln">length</span><span class="pun">);</span><span class="pln"> ptagsize</span><span class="pun">,</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;I'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">4</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_600"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> ptagsize </span><span class="pun">!=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">length</span><span class="pun">+</span><span class="lit">11</span><span class="pun">):</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_601"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'invalid previous tag-size found:'</span><span class="pun">,</span><span class="pln"> ptagsize</span><span class="pun">,</span><span class="pln"> </span><span class="str">'!='</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">length</span><span class="pun">+</span><span class="lit">11</span><span class="pun">),</span><span class="str">'ignored.'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_602"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">client </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">break</span><span class="pln"> </span><span class="com"># if it is closed</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_603"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com">#hdr = Header(3 if type == Message.AUDIO else 4, ts if ts &lt; 0xffffff else 0xffffff, length, type, stream.id)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_604"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hdr </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Header</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> ts</span><span class="pun">,</span><span class="pln"> length</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">id</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_605"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">(</span><span class="pln">hdr</span><span class="pun">,</span><span class="pln"> body</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_606"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if _debug: print 'FLV.read() length=', length, 'hdr=', hdr</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_607"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if hdr.type == Message.AUDIO: print 'r', hdr.type, hdr.time</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_608"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">DATA</span><span class="pun">:</span><span class="pln"> </span><span class="com"># metadata</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_609"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; amfReader </span><span class="pun">=</span><span class="pln"> amf</span><span class="pun">.</span><span class="pln">AMF0</span><span class="pun">(</span><span class="pln">body</span><span class="pun">)</span><span class="pln"> </span><span class="com"># TODO: use AMF3 if needed</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_610"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name </span><span class="pun">=</span><span class="pln"> amfReader</span><span class="pun">.</span><span class="pln">read</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_611"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; obj </span><span class="pun">=</span><span class="pln"> amfReader</span><span class="pun">.</span><span class="pln">read</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_612"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'FLV.read()'</span><span class="pun">,</span><span class="pln"> name</span><span class="pun">,</span><span class="pln"> repr</span><span class="pun">(</span><span class="pln">obj</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_613"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">msg</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_614"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> ts </span><span class="pun">&gt;</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsp</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_615"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; diff</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsp </span><span class="pun">=</span><span class="pln"> ts </span><span class="pun">-</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsp</span><span class="pun">,</span><span class="pln"> ts<br></span></td></tr><tr id="sl_svn154_616"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'FLV.read() sleep'</span><span class="pun">,</span><span class="pln"> diff<br></span></td></tr><tr id="sl_svn154_617"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> multitask</span><span class="pun">.</span><span class="pln">sleep</span><span class="pun">(</span><span class="pln">diff </span><span class="pun">/</span><span class="pln"> </span><span class="lit">1000.0</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_618"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">StopIteration</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_619"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_620"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'closing the reader'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sys </span><span class="kwd">and</span><span class="pln"> sys</span><span class="pun">.</span><span class="pln">exc_info</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_621"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_622"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">close</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_623"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_624"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_625"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_626"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> seek</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> offset</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_627"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''For file reader, try seek to the given time. The offset is in millisec'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_628"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="str">'read'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_629"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'FLV.seek() offset='</span><span class="pun">,</span><span class="pln"> offset</span><span class="pun">,</span><span class="pln"> </span><span class="str">'current tsp='</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsp<br></span></td></tr><tr id="sl_svn154_630"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">SEEK_SET</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_631"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; magic</span><span class="pun">,</span><span class="pln"> version</span><span class="pun">,</span><span class="pln"> flags</span><span class="pun">,</span><span class="pln"> length </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'!3sBBI'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">9</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_632"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> length </span><span class="pun">&gt;</span><span class="pln"> </span><span class="lit">9</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="pln">length</span><span class="pun">-</span><span class="lit">9</span><span class="pun">,</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">SEEK_CUR</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_633"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="lit">4</span><span class="pun">,</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">SEEK_CUR</span><span class="pun">)</span><span class="pln"> </span><span class="com"># ignore first previous tag size</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_634"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">tsp</span><span class="pun">,</span><span class="pln"> ts </span><span class="pun">=</span><span class="pln"> int</span><span class="pun">(</span><span class="pln">offset</span><span class="pun">),</span><span class="pln"> </span><span class="lit">0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_635"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsp </span><span class="pun">&gt;</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="kwd">and</span><span class="pln"> ts </span><span class="pun">&lt;</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">tsp</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_636"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bytes </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">11</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_637"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> bytes</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">break</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_638"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type</span><span class="pun">,</span><span class="pln"> len0</span><span class="pun">,</span><span class="pln"> len1</span><span class="pun">,</span><span class="pln"> ts0</span><span class="pun">,</span><span class="pln"> ts1</span><span class="pun">,</span><span class="pln"> ts2</span><span class="pun">,</span><span class="pln"> sid0</span><span class="pun">,</span><span class="pln"> sid1 </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;BBHBHBBH'</span><span class="pun">,</span><span class="pln"> bytes</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_639"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; length </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">len0 </span><span class="pun">&lt;&lt;</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> len1</span><span class="pun">;</span><span class="pln"> ts </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts0 </span><span class="pun">&lt;&lt;</span><span class="pln"> </span><span class="lit">16</span><span class="pun">)</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts1 </span><span class="pun">&amp;</span><span class="pln"> </span><span class="lit">0x0ffff</span><span class="pun">)</span><span class="pln"> </span><span class="pun">|</span><span class="pln"> </span><span class="pun">(</span><span class="pln">ts2 </span><span class="pun">&lt;&lt;</span><span class="pln"> </span><span class="lit">24</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_640"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="pln">length</span><span class="pun">,</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">SEEK_CUR</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_641"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ptagsize</span><span class="pun">,</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">unpack</span><span class="pun">(</span><span class="str">'&gt;I'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">read</span><span class="pun">(</span><span class="lit">4</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_642"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> ptagsize </span><span class="pun">!=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">length</span><span class="pun">+</span><span class="lit">11</span><span class="pun">):</span><span class="pln"> </span><span class="kwd">break</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_643"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'FLV.seek() new ts='</span><span class="pun">,</span><span class="pln"> ts</span><span class="pun">,</span><span class="pln"> </span><span class="str">'tell'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">fp</span><span class="pun">.</span><span class="pln">tell</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_644"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_645"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_646"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Stream</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_647"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'''The stream object that is used for RTMP stream.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_648"><td class="source"><span class="pln">&nbsp; &nbsp; count </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">;</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_649"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_650"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name </span><span class="pun">=</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="str">''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_651"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">recordfile </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">playfile </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"> </span><span class="com"># so that it doesn't complain about missing attribute</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_652"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">queue </span><span class="pun">=</span><span class="pln"> multitask</span><span class="pun">.</span><span class="typ">Queue</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_653"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">_name </span><span class="pun">=</span><span class="pln"> </span><span class="str">'Stream['</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> str</span><span class="pun">(</span><span class="typ">Stream</span><span class="pun">.</span><span class="pln">count</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">']'</span><span class="pun">;</span><span class="pln"> </span><span class="typ">Stream</span><span class="pun">.</span><span class="pln">count </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_654"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">,</span><span class="pln"> </span><span class="str">'created'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_655"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_656"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> close</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_657"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">,</span><span class="pln"> </span><span class="str">'closing'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_658"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">recordfile </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">recordfile</span><span class="pun">.</span><span class="pln">close</span><span class="pun">();</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">recordfile </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_659"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">playfile </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">playfile</span><span class="pun">.</span><span class="pln">close</span><span class="pun">();</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">playfile </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_660"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">client </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"> </span><span class="com"># to clear the reference</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_661"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_662"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_663"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __repr__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_664"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_name</span><span class="pun">;</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_665"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_666"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> recv</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_667"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Generator to receive new Message on this stream, or None if stream is closed.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_668"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">get</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_669"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_670"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> send</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_671"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Method to send a Message or Command on this stream.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_672"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> isinstance</span><span class="pun">(</span><span class="pln">msg</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_673"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg </span><span class="pun">=</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_674"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; msg</span><span class="pun">.</span><span class="pln">streamId </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">id<br></span></td></tr><tr id="sl_svn154_675"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if _debug: print self,'send'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_676"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">client </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">msg</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_677"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_678"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Client</span><span class="pun">(</span><span class="typ">Protocol</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_679"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'''The client object represents a single connected client to the server.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_680"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> sock</span><span class="pun">,</span><span class="pln"> server</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_681"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="typ">Protocol</span><span class="pun">.</span><span class="pln">__init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> sock</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_682"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">server</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">streams</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_nextCallId</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_nextStreamId</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">objectEncoding </span><span class="pun">=</span><span class="pln"> </span><span class="pun">\</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_683"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; server</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp;</span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="pun">{},</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="lit">2</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="lit">0.0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_684"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">queue </span><span class="pun">=</span><span class="pln"> multitask</span><span class="pun">.</span><span class="typ">Queue</span><span class="pun">()</span><span class="pln"> </span><span class="com"># receive queue used by application</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_685"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">parse</span><span class="pun">());</span><span class="pln"> multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">write</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_686"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_687"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> recv</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_688"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Generator to receive new Message (msg, arg) on this stream, or (None,None) if stream is closed.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_689"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">get</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_690"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_691"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> connectionClosed</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_692"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Called when the client drops the connection'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_693"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="str">'Client.connectionClosed'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_694"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="kwd">None</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_695"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">put</span><span class="pun">((</span><span class="kwd">None</span><span class="pun">,</span><span class="kwd">None</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_696"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_697"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> messageReceived</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_698"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC </span><span class="kwd">or</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC3</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">and</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">streamId </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_699"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">.</span><span class="pln">fromMessage</span><span class="pun">(</span><span class="pln">msg</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_700"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if _debug: print 'rtmp.Client.messageReceived cmd=', cmd</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_701"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name </span><span class="pun">==</span><span class="pln"> </span><span class="str">'connect'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_702"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">agent </span><span class="pun">=</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">cmdData<br></span></td></tr><tr id="sl_svn154_703"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'connect'</span><span class="pun">,</span><span class="pln"> </span><span class="str">', '</span><span class="pun">.</span><span class="pln">join</span><span class="pun">([</span><span class="str">'%s=%r'</span><span class="pun">%(</span><span class="pln">x</span><span class="pun">,</span><span class="pln"> getattr</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">,</span><span class="pln"> x</span><span class="pun">))</span><span class="pln"> </span><span class="kwd">for</span><span class="pln"> x </span><span class="kwd">in</span><span class="pln"> </span><span class="str">'app flashVer swfUrl tcUrl fpad capabilities audioCodecs videoCodecs videoFunction pageUrl objectEncoding'</span><span class="pun">.</span><span class="pln">split</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> hasattr</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">,</span><span class="pln"> x</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_704"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">objectEncoding </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">.</span><span class="pln">objectEncoding </span><span class="kwd">if</span><span class="pln"> hasattr</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">,</span><span class="pln"> </span><span class="str">'objectEncoding'</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="lit">0.0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_705"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">server</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">put</span><span class="pun">((</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">))</span><span class="pln"> </span><span class="com"># new connection</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_706"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name </span><span class="pun">==</span><span class="pln"> </span><span class="str">'createStream'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_707"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">'_result'</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">=</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">=</span><span class="pln">self</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">=</span><span class="pln">self</span><span class="pun">.</span><span class="pln">rpc</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">=[</span><span class="pln">self</span><span class="pun">.</span><span class="pln">_nextStreamId</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_708"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_709"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_710"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Stream</span><span class="pun">(</span><span class="pln">self</span><span class="pun">)</span><span class="pln"> </span><span class="com"># create a stream object</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_711"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">id </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_nextStreamId<br></span></td></tr><tr id="sl_svn154_712"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">streams</span><span class="pun">[</span><span class="pln">self</span><span class="pun">.</span><span class="pln">_nextStreamId</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> stream<br></span></td></tr><tr id="sl_svn154_713"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">_nextStreamId </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_714"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_715"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">put</span><span class="pun">((</span><span class="str">'stream'</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">))</span><span class="pln"> </span><span class="com"># also notify others of our new stream</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_716"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name </span><span class="pun">==</span><span class="pln"> </span><span class="str">'closeStream'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_717"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">assert</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">streamId </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">streams<br></span></td></tr><tr id="sl_svn154_718"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">streams</span><span class="pun">[</span><span class="pln">msg</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">].</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">put</span><span class="pun">(</span><span class="kwd">None</span><span class="pun">)</span><span class="pln"> </span><span class="com"># notify closing to others</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_719"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">del</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">streams</span><span class="pun">[</span><span class="pln">msg</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_720"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_721"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if _debug: print 'Client.messageReceived cmd=', cmd</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_722"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">put</span><span class="pun">((</span><span class="str">'command'</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">))</span><span class="pln"> </span><span class="com"># RPC call</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_723"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"> </span><span class="com"># this has to be a message on the stream</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_724"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">assert</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">streamId </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_725"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">assert</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">streamId </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">streams<br></span></td></tr><tr id="sl_svn154_726"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if _debug: print self.streams[msg.streamId], 'recv'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_727"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">streams</span><span class="pun">[</span><span class="pln">msg</span><span class="pun">.</span><span class="pln">streamId</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_728"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">:</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">client </span><span class="pun">=</span><span class="pln"> self <br></span></td></tr><tr id="sl_svn154_729"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">put</span><span class="pun">(</span><span class="pln">msg</span><span class="pun">)</span><span class="pln"> </span><span class="com"># give it to stream</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_730"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_731"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="lit">@property</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_732"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> rpc</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_733"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># TODO: reverting r141 since it causes exception in setting self.rpc</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_734"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">objectEncoding </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0.0</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC3<br></span></td></tr><tr id="sl_svn154_735"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_736"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> accept</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_737"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Method to accept an incoming client.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_738"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_739"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; response</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_result'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">rpc<br></span></td></tr><tr id="sl_svn154_740"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'Client.accept() objectEncoding='</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">objectEncoding<br></span></td></tr><tr id="sl_svn154_741"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; arg </span><span class="pun">=</span><span class="pln"> amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'status'</span><span class="pun">,</span><span class="pln"> code</span><span class="pun">=</span><span class="str">'NetConnection.Connect.Success'</span><span class="pun">,</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_742"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;description</span><span class="pun">=</span><span class="str">'Connection succeeded.'</span><span class="pun">,</span><span class="pln"> fmsVer</span><span class="pun">=</span><span class="str">'rtmplite/8,2'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_743"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hasattr</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">,</span><span class="pln"> </span><span class="str">'objectEncoding'</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_744"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; arg</span><span class="pun">.</span><span class="pln">objectEncoding</span><span class="pun">,</span><span class="pln"> arg</span><span class="pun">.</span><span class="pln">details </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">objectEncoding</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_745"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; response</span><span class="pun">.</span><span class="pln">setArg</span><span class="pun">(</span><span class="pln">arg</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_746"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_747"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_748"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> rejectConnection</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> reason</span><span class="pun">=</span><span class="str">''</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_749"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Method to reject an incoming client.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_750"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_751"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; response</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_error'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">rpc<br></span></td></tr><tr id="sl_svn154_752"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; response</span><span class="pun">.</span><span class="pln">setArg</span><span class="pun">(</span><span class="pln">amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'status'</span><span class="pun">,</span><span class="pln"> code</span><span class="pun">=</span><span class="str">'NetConnection.Connect.Rejected'</span><span class="pun">,</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_753"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description</span><span class="pun">=</span><span class="pln">reason</span><span class="pun">,</span><span class="pln"> fmsVer</span><span class="pun">=</span><span class="str">'rtmplite/8,2'</span><span class="pun">,</span><span class="pln"> details</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_754"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_755"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_756"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> redirectConnection</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> url</span><span class="pun">,</span><span class="pln"> reason</span><span class="pun">=</span><span class="str">'Connection failed'</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_757"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Method to redirect an incoming client to the given url.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_758"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_759"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; response</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> </span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="str">'_error'</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">rpc<br></span></td></tr><tr id="sl_svn154_760"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; extra </span><span class="pun">=</span><span class="pln"> dict</span><span class="pun">(</span><span class="pln">code</span><span class="pun">=</span><span class="lit">302</span><span class="pun">,</span><span class="pln"> redirect</span><span class="pun">=</span><span class="pln">url</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_761"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; response</span><span class="pun">.</span><span class="pln">setArg</span><span class="pun">(</span><span class="pln">amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'status'</span><span class="pun">,</span><span class="pln"> code</span><span class="pun">=</span><span class="str">'NetConnection.Connect.Rejected'</span><span class="pun">,</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_762"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description</span><span class="pun">=</span><span class="pln">reason</span><span class="pun">,</span><span class="pln"> fmsVer</span><span class="pun">=</span><span class="str">'rtmplite/8,2'</span><span class="pun">,</span><span class="pln"> details</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> ex</span><span class="pun">=</span><span class="pln">extra</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_763"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_764"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_765"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> call</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> method</span><span class="pun">,</span><span class="pln"> </span><span class="pun">*</span><span class="pln">args</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_766"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Call a (callback) method on the client.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_767"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; cmd </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_768"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; cmd</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_nextCallId</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> method</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">rpc<br></span></td></tr><tr id="sl_svn154_769"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">cmdData </span><span class="pun">=</span><span class="pln"> args</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_770"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">_nextCallId </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_771"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'Client.call method='</span><span class="pun">,</span><span class="pln"> method</span><span class="pun">,</span><span class="pln"> </span><span class="str">'args='</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">,</span><span class="pln"> </span><span class="str">' msg='</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_772"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_773"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_774"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> createStream</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_775"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">''' Create a stream on the server side'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_776"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; stream </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Stream</span><span class="pun">(</span><span class="pln">self</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_777"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">id </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_nextStreamId<br></span></td></tr><tr id="sl_svn154_778"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">streams</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">id</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> stream<br></span></td></tr><tr id="sl_svn154_779"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">_nextStreamId </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_780"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> stream<br></span></td></tr><tr id="sl_svn154_781"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_782"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_783"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Server</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_784"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'''A RTMP server listens for incoming connections and informs the app.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_785"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> sock</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_786"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Create an RTMP server on the given bound TCP socket. The server will terminate<br></span></td></tr><tr id="sl_svn154_787"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; when the socket is disconnected, or some other error occurs in listening.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_788"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">sock </span><span class="pun">=</span><span class="pln"> sock<br></span></td></tr><tr id="sl_svn154_789"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">queue </span><span class="pun">=</span><span class="pln"> multitask</span><span class="pun">.</span><span class="typ">Queue</span><span class="pun">()</span><span class="pln"> &nbsp;</span><span class="com"># queue to receive incoming client connections</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_790"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">run</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_791"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_792"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> recv</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_793"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Generator to wait for incoming client connections on this server and return<br></span></td></tr><tr id="sl_svn154_794"><td class="source"><span class="str">&nbsp; &nbsp; &nbsp; &nbsp; (client, args) or (None, None) if the socket is closed or some error.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_795"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">get</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_796"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_797"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> run</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_798"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_799"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> </span><span class="kwd">True</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_800"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sock</span><span class="pun">,</span><span class="pln"> remote </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> multitask</span><span class="pun">.</span><span class="pln">accept</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">))</span><span class="pln"> &nbsp;</span><span class="com"># receive client TCP</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_801"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> sock </span><span class="pun">==</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_802"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'rtmp.Server accept(sock) returned None.'</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_803"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">break</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_804"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'connection received from'</span><span class="pun">,</span><span class="pln"> remote<br></span></td></tr><tr id="sl_svn154_805"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sock</span><span class="pun">.</span><span class="pln">setsockopt</span><span class="pun">(</span><span class="pln">socket</span><span class="pun">.</span><span class="pln">IPPROTO_TCP</span><span class="pun">,</span><span class="pln"> socket</span><span class="pun">.</span><span class="pln">TCP_NODELAY</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">)</span><span class="pln"> </span><span class="com"># make it non-block</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_806"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; client </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Client</span><span class="pun">(</span><span class="pln">sock</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_807"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">GeneratorExit</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"> </span><span class="com"># terminate</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_808"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_809"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'rtmp.Server exception '</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sys </span><span class="kwd">and</span><span class="pln"> sys</span><span class="pun">.</span><span class="pln">exc_info</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_810"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_811"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_812"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">.</span><span class="pln">close</span><span class="pun">();</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">sock </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_813"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_814"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_815"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">queue</span><span class="pun">.</span><span class="pln">put</span><span class="pun">((</span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_816"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">queue </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_817"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_818"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">App</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_819"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'''An application instance containing any number of streams. Except for constructor all methods are generators.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_820"><td class="source"><span class="pln">&nbsp; &nbsp; count </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_821"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_822"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">name </span><span class="pun">=</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">__class__</span><span class="pun">.</span><span class="pln">__name__</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">'['</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> str</span><span class="pun">(</span><span class="typ">App</span><span class="pun">.</span><span class="pln">count</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">']'</span><span class="pun">;</span><span class="pln"> </span><span class="typ">App</span><span class="pun">.</span><span class="pln">count </span><span class="pun">+=</span><span class="pln"> </span><span class="lit">1</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_823"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">players</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">publishers</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_clients </span><span class="pun">=</span><span class="pln"> </span><span class="pun">{},</span><span class="pln"> </span><span class="pun">{},</span><span class="pln"> </span><span class="pun">[]</span><span class="pln"> </span><span class="com"># Streams indexed by stream name, and list of clients</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_824"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'created'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_825"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __del__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_826"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'destroyed'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_827"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="lit">@property</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_828"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> clients</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_829"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''everytime this property is accessed it returns a new list of clients connected to this instance.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_830"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_clients</span><span class="pun">[</span><span class="lit">1</span><span class="pun">:]</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">_clients </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">[]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_831"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onConnect</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> </span><span class="pun">*</span><span class="pln">args</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_832"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onConnect'</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path<br></span></td></tr><tr id="sl_svn154_833"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">True</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_834"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onDisconnect</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_835"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onDisconnect'</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path<br></span></td></tr><tr id="sl_svn154_836"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onPublish</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_837"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onPublish'</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name<br></span></td></tr><tr id="sl_svn154_838"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onClose</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_839"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onClose'</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name<br></span></td></tr><tr id="sl_svn154_840"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onPlay</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_841"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onPlay'</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name<br></span></td></tr><tr id="sl_svn154_842"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onStop</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_843"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onStop'</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name<br></span></td></tr><tr id="sl_svn154_844"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onCommand</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">,</span><span class="pln"> </span><span class="pun">*</span><span class="pln">args</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_845"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onCommand'</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">,</span><span class="pln"> args<br></span></td></tr><tr id="sl_svn154_846"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onStatus</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> info</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_847"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onStatus'</span><span class="pun">,</span><span class="pln"> info<br></span></td></tr><tr id="sl_svn154_848"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onResult</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> result</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_849"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onResult'</span><span class="pun">,</span><span class="pln"> result<br></span></td></tr><tr id="sl_svn154_850"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onPublishData</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">):</span><span class="pln"> </span><span class="com"># this is invoked every time some media packet is received from published stream.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_851"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">True</span><span class="pln"> </span><span class="com"># should return True so that the data is actually published in that stream</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_852"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onPlayData</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_853"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">True</span><span class="pln"> </span><span class="com"># should return True so that data will be actually played in that stream</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_854"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_855"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">Wirecast</span><span class="pun">(</span><span class="typ">App</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_856"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'''A wrapper around App to workaround with wirecast publisher which does not send AVC seq periodically. It defines new stream variables<br></span></td></tr><tr id="sl_svn154_857"><td class="source"><span class="str">&nbsp; &nbsp; such as in publish stream 'metaData' to store first published metadata Message, and 'avcSeq' to store the last published AVC seq Message,<br></span></td></tr><tr id="sl_svn154_858"><td class="source"><span class="str">&nbsp; &nbsp; and in play stream 'avcIntra' to indicate if AVC intra frame has been sent or not. These variables are created onPublish and onPlay.<br></span></td></tr><tr id="sl_svn154_859"><td class="source"><span class="str">&nbsp; &nbsp; Additional, when onPlay it also also sends any published stream.metaData if found in associated publisher. When onPlayData for video, if<br></span></td></tr><tr id="sl_svn154_860"><td class="source"><span class="str">&nbsp; &nbsp; it detects AVC seq it sets avcIntra so that it is not explicitly sent. This is the case with Flash Player publisher. When onPlayData for video,<br></span></td></tr><tr id="sl_svn154_861"><td class="source"><span class="str">&nbsp; &nbsp; if it detects avcIntra is not set, it discards the packet until AVC NALU or seq is received. If NALU is received but previous seq is not received<br></span></td></tr><tr id="sl_svn154_862"><td class="source"><span class="str">&nbsp; &nbsp; it uses the publisher's avcSeq message to send before this NALU if found.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_863"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_864"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="typ">App</span><span class="pun">.</span><span class="pln">__init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_865"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_866"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onPublish</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_867"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="typ">App</span><span class="pun">.</span><span class="pln">onPublish</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_868"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> hasattr</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> </span><span class="str">'metaData'</span><span class="pun">):</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">metaData </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_869"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> hasattr</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> </span><span class="str">'avcSeq'</span><span class="pun">):</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">avcSeq </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_870"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_871"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onPlay</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_872"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="typ">App</span><span class="pun">.</span><span class="pln">onPlay</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_873"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> hasattr</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> </span><span class="str">'avcIntra'</span><span class="pun">):</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">avcIntra </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">False</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_874"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; publisher </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">publishers</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_875"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> publisher </span><span class="kwd">and</span><span class="pln"> publisher</span><span class="pun">.</span><span class="pln">metaData</span><span class="pun">:</span><span class="pln"> </span><span class="com"># send published meta data to this player joining late</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_876"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">publisher</span><span class="pun">.</span><span class="pln">metaData</span><span class="pun">.</span><span class="pln">dup</span><span class="pun">()))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_877"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_878"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onPublishData</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_879"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">DATA </span><span class="kwd">and</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">metaData</span><span class="pun">:</span><span class="pln"> </span><span class="com"># store the first meta data on this published stream for late joining players</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_880"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">metaData </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">dup</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_881"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">VIDEO </span><span class="kwd">and</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[:</span><span class="lit">2</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="str">'\x17\x00'</span><span class="pun">:</span><span class="pln"> </span><span class="com"># H264Avc intra + seq, store it</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_882"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">avcSeq </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">dup</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_883"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">True</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_884"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_885"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> onPlayData</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_886"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">VIDEO</span><span class="pun">:</span><span class="pln"> </span><span class="com"># only video packets need special handling</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_887"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[:</span><span class="lit">2</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="str">'\x17\x00'</span><span class="pun">:</span><span class="pln"> </span><span class="com"># intra+seq is being sent, possibly by Flash Player publisher.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_888"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">avcIntra </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">True</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_889"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">avcIntra</span><span class="pun">:</span><span class="pln"> &nbsp;</span><span class="com"># intra frame hasn't been sent yet.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_890"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">data</span><span class="pun">[:</span><span class="lit">2</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="str">'\x17\x01'</span><span class="pun">:</span><span class="pln"> </span><span class="com"># intra+nalu is being sent, possibly by wirecast publisher.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_891"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; publisher </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">publishers</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_892"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> publisher </span><span class="kwd">and</span><span class="pln"> publisher</span><span class="pun">.</span><span class="pln">avcSeq</span><span class="pun">:</span><span class="pln"> </span><span class="com"># if a publisher exists</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_893"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> sendboth</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> msgs</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_894"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">avcIntra </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">True</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_895"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">for</span><span class="pln"> msg </span><span class="kwd">in</span><span class="pln"> msgs</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">msg</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_896"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">sendboth</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> </span><span class="pun">[</span><span class="pln">publisher</span><span class="pun">.</span><span class="pln">avcSeq</span><span class="pun">.</span><span class="pln">dup</span><span class="pun">(),</span><span class="pln"> message</span><span class="pun">]))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_897"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">False</span><span class="pln"> </span><span class="com"># so that caller doesn't send it again</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_898"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">False</span><span class="pln"> </span><span class="com"># drop until next intra video is sent</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_899"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">return</span><span class="pln"> </span><span class="kwd">True</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_900"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_901"><td class="source"><span class="kwd">class</span><span class="pln"> </span><span class="typ">FlashServer</span><span class="pun">(</span><span class="pln">object</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_902"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="str">'''A RTMP server to record and stream Flash video.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_903"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_904"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Construct a new FlashServer. It initializes the local members.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_905"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">sock </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">server </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">;</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_906"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">apps </span><span class="pun">=</span><span class="pln"> dict</span><span class="pun">({</span><span class="str">'*'</span><span class="pun">:</span><span class="pln"> </span><span class="typ">App</span><span class="pun">,</span><span class="pln"> </span><span class="str">'wirecast'</span><span class="pun">:</span><span class="pln"> </span><span class="typ">Wirecast</span><span class="pun">})</span><span class="pln"> </span><span class="com"># supported applications: * means any as in {'*': App}</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_907"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">clients </span><span class="pun">=</span><span class="pln"> dict</span><span class="pun">()</span><span class="pln"> &nbsp;</span><span class="com"># list of clients indexed by scope. First item in list is app instance.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_908"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">root </span><span class="pun">=</span><span class="pln"> </span><span class="str">''</span><span class="pun">;</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_909"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_910"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> start</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> host</span><span class="pun">=</span><span class="str">'0.0.0.0'</span><span class="pun">,</span><span class="pln"> port</span><span class="pun">=</span><span class="lit">1935</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_911"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''This should be used to start listening for RTMP connections on the given port, which defaults to 1935.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_912"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">server</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_913"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sock </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">sock </span><span class="pun">=</span><span class="pln"> socket</span><span class="pun">.</span><span class="pln">socket</span><span class="pun">(</span><span class="pln">type</span><span class="pun">=</span><span class="pln">socket</span><span class="pun">.</span><span class="pln">SOCK_STREAM</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_914"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sock</span><span class="pun">.</span><span class="pln">setsockopt</span><span class="pun">(</span><span class="pln">socket</span><span class="pun">.</span><span class="pln">SOL_SOCKET</span><span class="pun">,</span><span class="pln"> socket</span><span class="pun">.</span><span class="pln">SO_REUSEADDR</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_915"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sock</span><span class="pun">.</span><span class="pln">bind</span><span class="pun">((</span><span class="pln">host</span><span class="pun">,</span><span class="pln"> port</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_916"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'listening on '</span><span class="pun">,</span><span class="pln"> sock</span><span class="pun">.</span><span class="pln">getsockname</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_917"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sock</span><span class="pun">.</span><span class="pln">listen</span><span class="pun">(</span><span class="lit">5</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_918"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; server </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">server </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Server</span><span class="pun">(</span><span class="pln">sock</span><span class="pun">)</span><span class="pln"> </span><span class="com"># start rtmp server on that socket</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_919"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">serverlistener</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_920"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_921"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> stop</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_922"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'stopping Flash server'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_923"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">server </span><span class="kwd">and</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_924"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">sock</span><span class="pun">.</span><span class="pln">close</span><span class="pun">();</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">sock </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_925"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_926"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">server </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_927"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_928"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> serverlistener</span><span class="pun">(</span><span class="pln">self</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_929"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Server listener (generator). It accepts all connections and invokes client listener'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_930"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_931"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> </span><span class="kwd">True</span><span class="pun">:</span><span class="pln"> &nbsp;</span><span class="com"># main loop to receive new connections on the server</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_932"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; client</span><span class="pun">,</span><span class="pln"> args </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">server</span><span class="pun">.</span><span class="pln">recv</span><span class="pun">())</span><span class="pln"> </span><span class="com"># receive an incoming client connection.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_933"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># TODO: we should reject non-localhost client connections.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_934"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> client</span><span class="pun">:</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="com"># if the server aborted abnormally,</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_935"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">break</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># &nbsp; &nbsp;hence close the listener.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_936"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'client connection received'</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> args<br></span></td></tr><tr id="sl_svn154_937"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">objectEncoding </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="kwd">and</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">objectEncoding </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">3</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_938"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com">#if client.objectEncoding != 0:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_939"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">rejectConnection</span><span class="pun">(</span><span class="pln">reason</span><span class="pun">=</span><span class="str">'Unsupported encoding '</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">client</span><span class="pun">.</span><span class="pln">objectEncoding</span><span class="pun">)</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">'. Please use NetConnection.defaultObjectEncoding=ObjectEncoding.AMF0'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_940"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">connectionClosed</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_941"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_942"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; client</span><span class="pun">.</span><span class="pln">path </span><span class="pun">=</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">client</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">.</span><span class="pln">app</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> hasattr</span><span class="pun">(</span><span class="pln">client</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">,</span><span class="pln"> </span><span class="str">'app'</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">client</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">[</span><span class="str">'app'</span><span class="pun">])</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> isinstance</span><span class="pun">(</span><span class="pln">client</span><span class="pun">.</span><span class="pln">agent</span><span class="pun">,</span><span class="pln"> dict</span><span class="pun">)</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_943"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_944"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">rejectConnection</span><span class="pun">(</span><span class="pln">reason</span><span class="pun">=</span><span class="str">'Missing app path'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_945"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">break</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_946"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name</span><span class="pun">,</span><span class="pln"> ignore</span><span class="pun">,</span><span class="pln"> scope </span><span class="pun">=</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">partition</span><span class="pun">(</span><span class="str">'/'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_947"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="str">'*'</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">apps </span><span class="kwd">and</span><span class="pln"> name </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">apps</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_948"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">rejectConnection</span><span class="pun">(</span><span class="pln">reason</span><span class="pun">=</span><span class="str">'Application not found: '</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> name</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_949"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"> </span><span class="com"># create application instance as needed and add in our list</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_950"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'name='</span><span class="pun">,</span><span class="pln"> name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'name in apps'</span><span class="pun">,</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">name </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">apps</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_951"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; app </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">apps</span><span class="pun">[</span><span class="pln">name</span><span class="pun">]</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> name </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">apps </span><span class="kwd">else</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">apps</span><span class="pun">[</span><span class="str">'*'</span><span class="pun">]</span><span class="pln"> </span><span class="com"># application class</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_952"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">:</span><span class="pln"> inst </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">][</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_953"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"> inst </span><span class="pun">=</span><span class="pln"> app</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_954"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_955"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win_ack </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_956"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; win_ack</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> win_ack</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> win_ack</span><span class="pun">.</span><span class="pln">data </span><span class="pun">=</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">WIN_ACK_SIZE</span><span class="pun">,</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;L'</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">writeWinSize</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_957"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">win_ack</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_958"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_959"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;set_peer_bw = Message()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_960"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;set_peer_bw.time, set_peer_bw.type, set_peer_bw.data = client.relativeTime, Message.SET_PEER_BW, struct.pack('&gt;LB', client.writeWinSize, 1)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_961"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;client.writeMessage(set_peer_bw)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_962"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_963"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_964"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result </span><span class="pun">=</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">onConnect</span><span class="pun">(</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> </span><span class="pun">*</span><span class="pln">args</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_965"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_966"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> sys</span><span class="pun">.</span><span class="pln">exc_info</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_967"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">rejectConnection</span><span class="pun">(</span><span class="pln">reason</span><span class="pun">=</span><span class="str">'Exception on onConnect'</span><span class="pun">);</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_968"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">continue</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_969"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> result </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">True</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> result </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_970"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_971"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[</span><span class="pln">inst</span><span class="pun">];</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">_clients</span><span class="pun">=</span><span class="pln">self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_972"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">].</span><span class="pln">append</span><span class="pun">(</span><span class="pln">client</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_973"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> result </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">True</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_974"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">accept</span><span class="pun">()</span><span class="pln"> </span><span class="com"># TODO: else how to kill this task when rejectConnection() later</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_975"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">clientlistener</span><span class="pun">(</span><span class="pln">client</span><span class="pun">))</span><span class="pln"> </span><span class="com"># receive messages from client.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_976"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_977"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">rejectConnection</span><span class="pun">(</span><span class="pln">reason</span><span class="pun">=</span><span class="str">'Rejected in onConnect'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_978"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">GeneratorExit</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"> </span><span class="com"># terminate</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_979"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">StopIteration</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_980"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_981"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'serverlistener exception'</span><span class="pun">,</span><span class="pln"> traceback</span><span class="pun">.</span><span class="pln">print_exc</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_982"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_983"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> clientlistener</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_984"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Client listener (generator). It receives a command and invokes client handler, or receives a new stream and invokes streamlistener.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_985"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_986"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> </span><span class="kwd">True</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_987"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg</span><span class="pun">,</span><span class="pln"> arg </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">recv</span><span class="pun">())</span><span class="pln"> &nbsp; </span><span class="com"># receive new message from client</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_988"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> msg</span><span class="pun">:</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if the client disconnected,</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_989"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'connection closed from client'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_990"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">break</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># &nbsp; &nbsp;come out of listening loop.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_991"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> msg </span><span class="pun">==</span><span class="pln"> </span><span class="str">'command'</span><span class="pun">:</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span><span class="com"># handle a new command</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_992"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">clienthandler</span><span class="pun">(</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> arg</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_993"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> msg </span><span class="pun">==</span><span class="pln"> </span><span class="str">'stream'</span><span class="pun">:</span><span class="pln"> &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># a new stream is created, handle the stream.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_994"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; arg</span><span class="pun">.</span><span class="pln">client </span><span class="pun">=</span><span class="pln"> client<br></span></td></tr><tr id="sl_svn154_995"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">streamlistener</span><span class="pun">(</span><span class="pln">arg</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_996"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">StopIteration</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_997"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_998"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'clientlistener exception'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sys </span><span class="kwd">and</span><span class="pln"> sys</span><span class="pun">.</span><span class="pln">exc_info</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_999"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1000"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1001"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># client is disconnected, clear our state for application instance.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1002"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'cleaning up client'</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path<br></span></td></tr><tr id="sl_svn154_1003"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1004"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1005"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">][</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1006"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">].</span><span class="pln">remove</span><span class="pun">(</span><span class="pln">client</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1007"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">for</span><span class="pln"> stream </span><span class="kwd">in</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">streams</span><span class="pun">.</span><span class="pln">values</span><span class="pun">():</span><span class="pln"> </span><span class="com"># for all streams of this client</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1008"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">closehandler</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1009"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; client</span><span class="pun">.</span><span class="pln">streams</span><span class="pun">.</span><span class="pln">clear</span><span class="pun">()</span><span class="pln"> </span><span class="com"># and clear the collection of streams</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1010"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">path </span><span class="kwd">in</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients </span><span class="kwd">and</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">])</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">1</span><span class="pun">:</span><span class="pln"> </span><span class="com"># no more clients left, delete the instance.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1011"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'removing the application instance'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1012"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">][</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1013"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">_clients </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1014"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">del</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1015"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> inst </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">onDisconnect</span><span class="pun">(</span><span class="pln">client</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1016"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_1017"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'clientlistener exception'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sys </span><span class="kwd">and</span><span class="pln"> sys</span><span class="pun">.</span><span class="pln">exc_info</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1018"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1019"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> closehandler</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1020"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''A stream is closed explicitly when a closeStream command is received from given client.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1021"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">client </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1022"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">][</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1023"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name </span><span class="kwd">in</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">publishers </span><span class="kwd">and</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">publishers</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">]</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> stream</span><span class="pun">:</span><span class="pln"> </span><span class="com"># clear the published stream</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1024"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">onClose</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1025"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">del</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">publishers</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1026"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name </span><span class="kwd">in</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">players </span><span class="kwd">and</span><span class="pln"> stream </span><span class="kwd">in</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">players</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">]:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1027"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">onStop</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1028"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">players</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">].</span><span class="pln">remove</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1029"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">inst</span><span class="pun">.</span><span class="pln">players</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">])</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1030"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">del</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">players</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1031"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">close</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1032"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1033"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> clienthandler</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1034"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''A generator to handle a single command on the client.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1035"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; inst </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">][</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1036"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> inst</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1037"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name </span><span class="pun">==</span><span class="pln"> </span><span class="str">'_error'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1038"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hasattr</span><span class="pun">(</span><span class="pln">inst</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onStatus'</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1039"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result </span><span class="pun">=</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">onStatus</span><span class="pun">(</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">[</span><span class="lit">0</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1040"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name </span><span class="pun">==</span><span class="pln"> </span><span class="str">'_result'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1041"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> hasattr</span><span class="pun">(</span><span class="pln">inst</span><span class="pun">,</span><span class="pln"> </span><span class="str">'onResult'</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1042"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result </span><span class="pun">=</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">onResult</span><span class="pun">(</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">[</span><span class="lit">0</span><span class="pun">])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1043"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1044"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res</span><span class="pun">,</span><span class="pln"> code</span><span class="pun">,</span><span class="pln"> result </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(),</span><span class="pln"> </span><span class="str">'_result'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1045"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1046"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result </span><span class="pun">=</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">onCommand</span><span class="pun">(</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="pun">*</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1047"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1048"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'Client.call exception'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sys </span><span class="kwd">and</span><span class="pln"> sys</span><span class="pun">.</span><span class="pln">exc_info</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">)</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_1049"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; code </span><span class="pun">=</span><span class="pln"> </span><span class="str">'_error'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1050"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; args </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="pln">result</span><span class="pun">,)</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> result </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> dict</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1051"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> res</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> res</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> res</span><span class="pun">.</span><span class="pln">type </span><span class="pun">=</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> code</span><span class="pun">,</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">rpc<br></span></td></tr><tr id="sl_svn154_1052"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res</span><span class="pun">.</span><span class="pln">args</span><span class="pun">,</span><span class="pln"> res</span><span class="pun">.</span><span class="pln">cmdData </span><span class="pun">=</span><span class="pln"> args</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1053"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'Client.call method='</span><span class="pun">,</span><span class="pln"> code</span><span class="pun">,</span><span class="pln"> </span><span class="str">'args='</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">,</span><span class="pln"> </span><span class="str">' msg='</span><span class="pun">,</span><span class="pln"> res</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1054"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> client</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">res</span><span class="pun">.</span><span class="pln">toMessage</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1055"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1056"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1057"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> streamlistener</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1058"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Stream listener (generator). It receives stream message and invokes streamhandler.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1059"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1060"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">recordfile </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"> </span><span class="com"># so that it doesn't complain about missing attribute</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1061"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">while</span><span class="pln"> </span><span class="kwd">True</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1062"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">recv</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1063"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> msg</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1064"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'stream closed'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1065"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">closehandler</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1066"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">break</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1067"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># if _debug: msg</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1068"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">self</span><span class="pun">.</span><span class="pln">streamhandler</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> msg</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1069"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_1070"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'streamlistener exception'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sys </span><span class="kwd">and</span><span class="pln"> sys</span><span class="pun">.</span><span class="pln">exc_info</span><span class="pun">()</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1071"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1072"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> streamhandler</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1073"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''A generator to handle a single message on the stream.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1074"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1075"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC </span><span class="kwd">or</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">type </span><span class="pun">==</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">RPC3</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1076"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmd </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">.</span><span class="pln">fromMessage</span><span class="pun">(</span><span class="pln">message</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1077"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'streamhandler received cmd='</span><span class="pun">,</span><span class="pln"> cmd<br></span></td></tr><tr id="sl_svn154_1078"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name </span><span class="pun">==</span><span class="pln"> </span><span class="str">'publish'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1079"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">publishhandler</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1080"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name </span><span class="pun">==</span><span class="pln"> </span><span class="str">'play'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1081"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">playhandler</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1082"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name </span><span class="pun">==</span><span class="pln"> </span><span class="str">'closeStream'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1083"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self</span><span class="pun">.</span><span class="pln">closehandler</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1084"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">name </span><span class="pun">==</span><span class="pln"> </span><span class="str">'seek'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1085"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">seekhandler</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">)</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_1086"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">else</span><span class="pun">:</span><span class="pln"> </span><span class="com"># audio or video message</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1087"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">mediahandler</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1088"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">GeneratorExit</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1089"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">StopIteration</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1090"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_1091"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'exception in streamhandler'</span><span class="pun">,</span><span class="pln"> </span><span class="pun">(</span><span class="pln">sys </span><span class="kwd">and</span><span class="pln"> sys</span><span class="pun">.</span><span class="pln">exc_info</span><span class="pun">())</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1092"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1093"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> publishhandler</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1094"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''A new stream is published. Store the information in the application instance.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1095"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1096"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">mode </span><span class="pun">=</span><span class="pln"> </span><span class="str">'live'</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&lt;</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">[</span><span class="lit">1</span><span class="pun">]</span><span class="pln"> </span><span class="com"># live, record, append</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1097"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">name </span><span class="pun">=</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1098"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'publishing stream='</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'mode='</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">mode<br></span></td></tr><tr id="sl_svn154_1099"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name </span><span class="kwd">and</span><span class="pln"> </span><span class="str">'?'</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">:</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name </span><span class="pun">=</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">.</span><span class="pln">partition</span><span class="pun">(</span><span class="str">'?'</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1100"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">][</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1101"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name </span><span class="kwd">in</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">publishers</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1102"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">,</span><span class="pln"> </span><span class="str">'Stream name already in use'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1103"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">publishers</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> stream </span><span class="com"># store the client for publisher</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1104"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">onPublish</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1105"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1106"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path </span><span class="pun">=</span><span class="pln"> getfilename</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">root</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1107"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">mode </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">(</span><span class="str">'record'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'append'</span><span class="pun">):</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_1108"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">recordfile </span><span class="pun">=</span><span class="pln"> FLV</span><span class="pun">().</span><span class="pln">open</span><span class="pun">(</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">mode</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1109"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com"># elif stream.mode == 'live': FLV().delete(path) # TODO: this is commented out to avoid accidental delete</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1110"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">'onStatus'</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">=</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">=[</span><span class="pln">amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'status'</span><span class="pun">,</span><span class="pln"> code</span><span class="pun">=</span><span class="str">'NetStream.Publish.Start'</span><span class="pun">,</span><span class="pln"> description</span><span class="pun">=</span><span class="str">''</span><span class="pun">,</span><span class="pln"> details</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1111"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">response</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1112"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">,</span><span class="pln"> E</span><span class="pun">:</span><span class="pln"> </span><span class="com"># some error occurred. inform the app.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1113"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'error in publishing stream'</span><span class="pun">,</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">E</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1114"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">'onStatus'</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">=</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">=[</span><span class="pln">amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'error'</span><span class="pun">,</span><span class="pln">code</span><span class="pun">=</span><span class="str">'NetStream.Publish.BadName'</span><span class="pun">,</span><span class="pln">description</span><span class="pun">=</span><span class="pln">str</span><span class="pun">(</span><span class="pln">E</span><span class="pun">),</span><span class="pln">details</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1115"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">response</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1116"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_1117"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> playhandler</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1118"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''A new stream is being played. Just updated the players list with this stream.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1119"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1120"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">][</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1121"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name </span><span class="pun">=</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name </span><span class="pun">=</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"> &nbsp;</span><span class="com"># store the stream's name</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1122"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name </span><span class="kwd">and</span><span class="pln"> </span><span class="str">'?'</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">:</span><span class="pln"> name </span><span class="pun">=</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name </span><span class="pun">=</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">.</span><span class="pln">partition</span><span class="pun">(</span><span class="str">'?'</span><span class="pun">)[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1123"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start </span><span class="pun">=</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">[</span><span class="lit">1</span><span class="pun">]</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> len</span><span class="pun">(</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">)</span><span class="pln"> </span><span class="pun">&gt;=</span><span class="pln"> </span><span class="lit">2</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">-</span><span class="lit">2</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1124"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> name </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">players</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1125"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">players</span><span class="pun">[</span><span class="pln">name</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[]</span><span class="pln"> </span><span class="com"># initialize the players for this stream name</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1126"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">players</span><span class="pun">[</span><span class="pln">name</span><span class="pun">]:</span><span class="pln"> </span><span class="com"># store the stream as players of this name</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1127"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">players</span><span class="pun">[</span><span class="pln">name</span><span class="pun">].</span><span class="pln">append</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1128"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; task </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1129"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> start </span><span class="pun">&gt;=</span><span class="pln"> </span><span class="lit">0</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> start </span><span class="pun">==</span><span class="pln"> </span><span class="pun">-</span><span class="lit">2</span><span class="pln"> </span><span class="kwd">and</span><span class="pln"> name </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">in</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">publishers</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1130"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path </span><span class="pun">=</span><span class="pln"> getfilename</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">root</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1131"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> os</span><span class="pun">.</span><span class="pln">path</span><span class="pun">.</span><span class="pln">exists</span><span class="pun">(</span><span class="pln">path</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1132"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">playfile </span><span class="pun">=</span><span class="pln"> FLV</span><span class="pun">().</span><span class="pln">open</span><span class="pun">(</span><span class="pln">path</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1133"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> start </span><span class="pun">&gt;</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">playfile</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="pln">start</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1134"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; task </span><span class="pun">=</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">playfile</span><span class="pun">.</span><span class="pln">reader</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1135"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">elif</span><span class="pln"> start </span><span class="pun">&gt;=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">,</span><span class="pln"> </span><span class="str">'Stream name not found'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1136"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'playing stream='</span><span class="pun">,</span><span class="pln"> name</span><span class="pun">,</span><span class="pln"> </span><span class="str">'start='</span><span class="pun">,</span><span class="pln"> start<br></span></td></tr><tr id="sl_svn154_1137"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst</span><span class="pun">.</span><span class="pln">onPlay</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1138"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1139"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m0 = Message() # SetChunkSize</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1140"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m0.time, m0.type, m0.data = stream.client.relativeTime, Message.CHUNK_SIZE, struct.pack('&gt;L', stream.client.writeChunkSize)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1141"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yield stream.client.writeMessage(m0)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1142"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1143"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m1 = Message() # UserControl/StreamIsRecorded</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1144"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;m1.time, m1.type, m1.data = stream.client.relativeTime, Message.USER_CONTROL, struct.pack('&gt;HI', 4, stream.id)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1145"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yield stream.client.writeMessage(m1)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1146"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1147"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m2 </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">()</span><span class="pln"> </span><span class="com"># UserControl/StreamBegin</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1148"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m2</span><span class="pun">.</span><span class="pln">time</span><span class="pun">,</span><span class="pln"> m2</span><span class="pun">.</span><span class="pln">type</span><span class="pun">,</span><span class="pln"> m2</span><span class="pun">.</span><span class="pln">data </span><span class="pun">=</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> </span><span class="typ">Message</span><span class="pun">.</span><span class="pln">USER_CONTROL</span><span class="pun">,</span><span class="pln"> struct</span><span class="pun">.</span><span class="pln">pack</span><span class="pun">(</span><span class="str">'&gt;HI'</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">id</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1149"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">writeMessage</span><span class="pun">(</span><span class="pln">m2</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1150"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1151"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;response = Command(name='onStatus', id=cmd.id, args=[amf.Object(level='status',code='NetStream.Play.Reset', description=stream.name, details=None)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1152"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yield stream.send(response)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1153"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1154"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">'onStatus'</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">=</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">=[</span><span class="pln">amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'status'</span><span class="pun">,</span><span class="pln">code</span><span class="pun">=</span><span class="str">'NetStream.Play.Start'</span><span class="pun">,</span><span class="pln"> description</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> details</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1155"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">response</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1156"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1157"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;response = Command(name='onStatus', id=cmd.id, tm=stream.client.relativeTime, args=[amf.Object(level='status',code='NetStream.Play.PublishNotify', description=stream.name, details=None)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1158"><td class="source"><span class="com"># &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;yield stream.send(response)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1159"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1160"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> task </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"> multitask</span><span class="pun">.</span><span class="pln">add</span><span class="pun">(</span><span class="pln">task</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1161"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">,</span><span class="pln"> E</span><span class="pun">:</span><span class="pln"> </span><span class="com"># some error occurred. inform the app.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1162"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'error in playing stream'</span><span class="pun">,</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">E</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1163"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">'onStatus'</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">=</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">=[</span><span class="pln">amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'error'</span><span class="pun">,</span><span class="pln">code</span><span class="pun">=</span><span class="str">'NetStream.Play.StreamNotFound'</span><span class="pun">,</span><span class="pln">description</span><span class="pun">=</span><span class="pln">str</span><span class="pun">(</span><span class="pln">E</span><span class="pun">),</span><span class="pln">details</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1164"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">response</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1165"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1166"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> seekhandler</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> cmd</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1167"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''A stream is seeked to a new position. This is allowed only for play from a file.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1168"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1169"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; offset </span><span class="pun">=</span><span class="pln"> cmd</span><span class="pun">.</span><span class="pln">args</span><span class="pun">[</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1170"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">playfile </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">None</span><span class="pln"> </span><span class="kwd">or</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">playfile</span><span class="pun">.</span><span class="pln">type </span><span class="pun">!=</span><span class="pln"> </span><span class="str">'read'</span><span class="pun">:</span><span class="pln"> <br></span></td></tr><tr id="sl_svn154_1171"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">raise</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">,</span><span class="pln"> </span><span class="str">'Stream is not seekable'</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1172"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">playfile</span><span class="pun">.</span><span class="pln">seek</span><span class="pun">(</span><span class="pln">offset</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1173"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">'onStatus'</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">=</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">=[</span><span class="pln">amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'status'</span><span class="pun">,</span><span class="pln">code</span><span class="pun">=</span><span class="str">'NetStream.Seek.Notify'</span><span class="pun">,</span><span class="pln"> description</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> details</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1174"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">response</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1175"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">ValueError</span><span class="pun">,</span><span class="pln"> E</span><span class="pun">:</span><span class="pln"> </span><span class="com"># some error occurred. inform the app.</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1176"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> </span><span class="str">'error in seeking stream'</span><span class="pun">,</span><span class="pln"> str</span><span class="pun">(</span><span class="pln">E</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1177"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Command</span><span class="pun">(</span><span class="pln">name</span><span class="pun">=</span><span class="str">'onStatus'</span><span class="pun">,</span><span class="pln"> id</span><span class="pun">=</span><span class="pln">cmd</span><span class="pun">.</span><span class="pln">id</span><span class="pun">,</span><span class="pln"> tm</span><span class="pun">=</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">relativeTime</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">=[</span><span class="pln">amf</span><span class="pun">.</span><span class="typ">Object</span><span class="pun">(</span><span class="pln">level</span><span class="pun">=</span><span class="str">'error'</span><span class="pun">,</span><span class="pln">code</span><span class="pun">=</span><span class="str">'NetStream.Seek.Failed'</span><span class="pun">,</span><span class="pln">description</span><span class="pun">=</span><span class="pln">str</span><span class="pun">(</span><span class="pln">E</span><span class="pun">),</span><span class="pln">details</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">)])</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1178"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">response</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1179"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1180"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">def</span><span class="pln"> mediahandler</span><span class="pun">(</span><span class="pln">self</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1181"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="str">'''Handle incoming media on the stream, by sending to other stream in this application instance.'''</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1182"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">client </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1183"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inst </span><span class="pun">=</span><span class="pln"> self</span><span class="pun">.</span><span class="pln">clients</span><span class="pun">[</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">.</span><span class="pln">path</span><span class="pun">][</span><span class="lit">0</span><span class="pun">]</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1184"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result </span><span class="pun">=</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">onPublishData</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> stream</span><span class="pun">,</span><span class="pln"> message</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1185"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> result</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1186"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">for</span><span class="pln"> s </span><span class="kwd">in</span><span class="pln"> </span><span class="pun">(</span><span class="pln">inst</span><span class="pun">.</span><span class="pln">players</span><span class="pun">.</span><span class="pln">get</span><span class="pun">(</span><span class="pln">stream</span><span class="pun">.</span><span class="pln">name</span><span class="pun">,</span><span class="pln"> </span><span class="pun">[])):</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1187"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="com">#if _debug: print 'D', stream.name, s.name</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1188"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m </span><span class="pun">=</span><span class="pln"> message</span><span class="pun">.</span><span class="pln">dup</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1189"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result </span><span class="pun">=</span><span class="pln"> inst</span><span class="pun">.</span><span class="pln">onPlayData</span><span class="pun">(</span><span class="pln">s</span><span class="pun">.</span><span class="pln">client</span><span class="pun">,</span><span class="pln"> s</span><span class="pun">,</span><span class="pln"> m</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1190"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> result</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1191"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">yield</span><span class="pln"> s</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">m</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1192"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> stream</span><span class="pun">.</span><span class="pln">recordfile </span><span class="kwd">is</span><span class="pln"> </span><span class="kwd">not</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1193"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream</span><span class="pun">.</span><span class="pln">recordfile</span><span class="pun">.</span><span class="pln">write</span><span class="pun">(</span><span class="pln">message</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1194"><td class="source"><span class="pln"><br></span></td></tr><tr id="sl_svn154_1195"><td class="source"><span class="com"># The main routine to start, run and stop the service</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1196"><td class="source"><span class="kwd">if</span><span class="pln"> __name__ </span><span class="pun">==</span><span class="pln"> </span><span class="str">'__main__'</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1197"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">from</span><span class="pln"> optparse </span><span class="kwd">import</span><span class="pln"> </span><span class="typ">OptionParser</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1198"><td class="source"><span class="pln">&nbsp; &nbsp; parser </span><span class="pun">=</span><span class="pln"> </span><span class="typ">OptionParser</span><span class="pun">(</span><span class="pln">version</span><span class="pun">=</span><span class="str">'SVN $Revision$, $Date$'</span><span class="pun">.</span><span class="pln">replace</span><span class="pun">(</span><span class="str">'$'</span><span class="pun">,</span><span class="pln"> </span><span class="str">''</span><span class="pun">))</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1199"><td class="source"><span class="pln">&nbsp; &nbsp; parser</span><span class="pun">.</span><span class="pln">add_option</span><span class="pun">(</span><span class="str">'-i'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'--host'</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp;dest</span><span class="pun">=</span><span class="str">'host'</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp;default</span><span class="pun">=</span><span class="str">'0.0.0.0'</span><span class="pun">,</span><span class="pln"> help</span><span class="pun">=</span><span class="str">"listening IP address. Default '0.0.0.0'"</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1200"><td class="source"><span class="pln">&nbsp; &nbsp; parser</span><span class="pun">.</span><span class="pln">add_option</span><span class="pun">(</span><span class="str">'-p'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'--port'</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp;dest</span><span class="pun">=</span><span class="str">'port'</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp;default</span><span class="pun">=</span><span class="lit">1935</span><span class="pun">,</span><span class="pln"> type</span><span class="pun">=</span><span class="str">"int"</span><span class="pun">,</span><span class="pln"> help</span><span class="pun">=</span><span class="str">'listening port number. Default 1935'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1201"><td class="source"><span class="pln">&nbsp; &nbsp; parser</span><span class="pun">.</span><span class="pln">add_option</span><span class="pun">(</span><span class="str">'-r'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'--root'</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp;dest</span><span class="pun">=</span><span class="str">'root'</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp;default</span><span class="pun">=</span><span class="str">'./'</span><span class="pun">,</span><span class="pln"> &nbsp; &nbsp; &nbsp; help</span><span class="pun">=</span><span class="str">"document path prefix. Directory must end with /. Default './'"</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1202"><td class="source"><span class="pln">&nbsp; &nbsp; parser</span><span class="pun">.</span><span class="pln">add_option</span><span class="pun">(</span><span class="str">'-d'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'--verbose'</span><span class="pun">,</span><span class="pln"> dest</span><span class="pun">=</span><span class="str">'verbose'</span><span class="pun">,</span><span class="pln"> default</span><span class="pun">=</span><span class="kwd">False</span><span class="pun">,</span><span class="pln"> action</span><span class="pun">=</span><span class="str">'store_true'</span><span class="pun">,</span><span class="pln"> help</span><span class="pun">=</span><span class="str">'enable debug trace'</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1203"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="pun">(</span><span class="pln">options</span><span class="pun">,</span><span class="pln"> args</span><span class="pun">)</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> parser</span><span class="pun">.</span><span class="pln">parse_args</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1204"><td class="source"><span class="pln">&nbsp; &nbsp; <br></span></td></tr><tr id="sl_svn154_1205"><td class="source"><span class="pln">&nbsp; &nbsp; _debug </span><span class="pun">=</span><span class="pln"> options</span><span class="pun">.</span><span class="pln">verbose<br></span></td></tr><tr id="sl_svn154_1206"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">try</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1207"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; agent </span><span class="pun">=</span><span class="pln"> </span><span class="typ">FlashServer</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1208"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; agent</span><span class="pun">.</span><span class="pln">root </span><span class="pun">=</span><span class="pln"> options</span><span class="pun">.</span><span class="pln">root<br></span></td></tr><tr id="sl_svn154_1209"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; agent</span><span class="pun">.</span><span class="pln">start</span><span class="pun">(</span><span class="pln">options</span><span class="pun">.</span><span class="pln">host</span><span class="pun">,</span><span class="pln"> options</span><span class="pun">.</span><span class="pln">port</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1210"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> time</span><span class="pun">.</span><span class="pln">asctime</span><span class="pun">(),</span><span class="pln"> </span><span class="str">'Flash Server Starts - %s:%d'</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> </span><span class="pun">(</span><span class="pln">options</span><span class="pun">.</span><span class="pln">host</span><span class="pun">,</span><span class="pln"> options</span><span class="pun">.</span><span class="pln">port</span><span class="pun">)</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1211"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; multitask</span><span class="pun">.</span><span class="pln">run</span><span class="pun">()</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1212"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">except</span><span class="pln"> </span><span class="typ">KeyboardInterrupt</span><span class="pun">:</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1213"><td class="source"><span class="pln">&nbsp; &nbsp; &nbsp; &nbsp; </span><span class="kwd">pass</span><span class="pln"><br></span></td></tr><tr id="sl_svn154_1214"><td class="source"><span class="pln">&nbsp; &nbsp; </span><span class="kwd">if</span><span class="pln"> _debug</span><span class="pun">:</span><span class="pln"> </span><span class="kwd">print</span><span class="pln"> time</span><span class="pun">.</span><span class="pln">asctime</span><span class="pun">(),</span><span class="pln"> </span><span class="str">'Flash Server Stops'</span><span class="pln"><br></span></td></tr></tbody></table></pre>
<pre><table width="100%"><tbody><tr class="cursor_stop cursor_hidden"><td></td></tr></tbody></table></pre>
</td>
</tr></tbody></table>

 
<script type="text/javascript">
 var lineNumUnderMouse = -1;
 
 function gutterOver(num) {
 gutterOut();
 var newTR = document.getElementById('gr_svn154_' + num);
 if (newTR) {
 newTR.className = 'undermouse';
 }
 lineNumUnderMouse = num;
 }
 function gutterOut() {
 if (lineNumUnderMouse != -1) {
 var oldTR = document.getElementById(
 'gr_svn154_' + lineNumUnderMouse);
 if (oldTR) {
 oldTR.className = '';
 }
 lineNumUnderMouse = -1;
 }
 }
 var numsGenState = {table_base_id: 'nums_table_'};
 var srcGenState = {table_base_id: 'src_table_'};
 var alignerRunning = false;
 var startOver = false;
 function setLineNumberHeights() {
 if (alignerRunning) {
 startOver = true;
 return;
 }
 numsGenState.chunk_id = 0;
 numsGenState.table = document.getElementById('nums_table_0');
 numsGenState.row_num = 0;
 if (!numsGenState.table) {
 return; // Silently exit if no file is present.
 }
 srcGenState.chunk_id = 0;
 srcGenState.table = document.getElementById('src_table_0');
 srcGenState.row_num = 0;
 alignerRunning = true;
 continueToSetLineNumberHeights();
 }
 function rowGenerator(genState) {
 if (genState.row_num < genState.table.rows.length) {
 var currentRow = genState.table.rows[genState.row_num];
 genState.row_num++;
 return currentRow;
 }
 var newTable = document.getElementById(
 genState.table_base_id + (genState.chunk_id + 1));
 if (newTable) {
 genState.chunk_id++;
 genState.row_num = 0;
 genState.table = newTable;
 return genState.table.rows[0];
 }
 return null;
 }
 var MAX_ROWS_PER_PASS = 1000;
 function continueToSetLineNumberHeights() {
 var rowsInThisPass = 0;
 var numRow = 1;
 var srcRow = 1;
 while (numRow && srcRow && rowsInThisPass < MAX_ROWS_PER_PASS) {
 numRow = rowGenerator(numsGenState);
 srcRow = rowGenerator(srcGenState);
 rowsInThisPass++;
 if (numRow && srcRow) {
 if (numRow.offsetHeight != srcRow.offsetHeight) {
 numRow.firstChild.style.height = srcRow.offsetHeight + 'px';
 }
 }
 }
 if (rowsInThisPass >= MAX_ROWS_PER_PASS) {
 setTimeout(continueToSetLineNumberHeights, 10);
 } else {
 alignerRunning = false;
 if (startOver) {
 startOver = false;
 setTimeout(setLineNumberHeights, 500);
 }
 }
 }
 function initLineNumberHeights() {
 // Do 2 complete passes, because there can be races
 // between this code and prettify.
 startOver = true;
 setTimeout(setLineNumberHeights, 250);
 window.onresize = setLineNumberHeights;
 }
 initLineNumberHeights();
</script>

 
 
 <div id="log">
 <div style="text-align:right">
 <a class="ifCollapse" href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#" onclick="_toggleMeta(this); return false">Show details</a>
 <a class="ifExpand" href="http://code.google.com/p/rtmplite/source/browse/trunk/rtmp.py#" onclick="_toggleMeta(this); return false">Hide details</a>
 </div>
 <div class="ifExpand">
 
 
 <div class="pmeta_bubble_bg" style="border:1px solid white">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner">
 <div id="changelog">
 <p>Change log</p>
 <div>
 <a href="http://code.google.com/p/rtmplite/source/detail?spec=svn154&r=145">r145</a>
 by kundan10
 on Feb 6, 2012
 &nbsp; <a href="http://code.google.com/p/rtmplite/source/diff?spec=svn154&r=145&format=side&path=/trunk/rtmp.py&old_path=/trunk/rtmp.py&old=142">Diff</a>
 </div>
 <pre>patch submitted by Teeed teeed@na1noc.pl
on Jan 16 to fix the result fron onCommand</pre>
 </div>
 
 
 
 
 
 
 <script type="text/javascript">
 var detail_url = '/p/rtmplite/source/detail?r=145&spec=svn154';
 var publish_url = '/p/rtmplite/source/detail?r=145&spec=svn154#publish';
 // describe the paths of this revision in javascript.
 var changed_paths = [];
 var changed_urls = [];
 
 changed_paths.push('/trunk/rtmp.py');
 changed_urls.push('/p/rtmplite/source/browse/trunk/rtmp.py?r\x3d145\x26spec\x3dsvn154');
 
 var selected_path = '/trunk/rtmp.py';
 
 
 changed_paths.push('/trunk/siprtmp_gevent.py');
 changed_urls.push('/p/rtmplite/source/browse/trunk/siprtmp_gevent.py?r\x3d145\x26spec\x3dsvn154');
 
 
 function getCurrentPageIndex() {
 for (var i = 0; i < changed_paths.length; i++) {
 if (selected_path == changed_paths[i]) {
 return i;
 }
 }
 }
 function getNextPage() {
 var i = getCurrentPageIndex();
 if (i < changed_paths.length - 1) {
 return changed_urls[i + 1];
 }
 return null;
 }
 function getPreviousPage() {
 var i = getCurrentPageIndex();
 if (i > 0) {
 return changed_urls[i - 1];
 }
 return null;
 }
 function gotoNextPage() {
 var page = getNextPage();
 if (!page) {
 page = detail_url;
 }
 window.location = page;
 }
 function gotoPreviousPage() {
 var page = getPreviousPage();
 if (!page) {
 page = detail_url;
 }
 window.location = page;
 }
 function gotoDetailPage() {
 window.location = detail_url;
 }
 function gotoPublishPage() {
 window.location = publish_url;
 }
</script>

 
 <style type="text/css">
 #review_nav {
 border-top: 3px solid white;
 padding-top: 6px;
 margin-top: 1em;
 }
 #review_nav td {
 vertical-align: middle;
 }
 #review_nav select {
 margin: .5em 0;
 }
 </style>
 <div id="review_nav">
 <table><tbody><tr><td>Go to:&nbsp;</td><td>
 <select name="files_in_rev" onchange="window.location=this.value">
 
 <option value="/p/rtmplite/source/browse/trunk/rtmp.py?r=145&amp;spec=svn154" selected="selected">/trunk/rtmp.py</option>
 
 <option value="/p/rtmplite/source/browse/trunk/siprtmp_gevent.py?r=145&amp;spec=svn154">/trunk/siprtmp_gevent.py</option>
 
 </select>
 </td></tr></tbody></table>
 
 
 



 
 </div>
 
 
 </div>
 <div class="round1"></div>
 <div class="round2"></div>
 <div class="round4"></div>
 </div>
 <div class="pmeta_bubble_bg" style="border:1px solid white">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner">
 <div id="older_bubble">
 <p>Older revisions</p>
 
 
 <div class="closed" style="margin-bottom:3px;">
 <img class="ifClosed" onclick="_toggleHidden(this)" src="./rtmp_files/plus.gif">
 <img class="ifOpened" onclick="_toggleHidden(this)" src="./rtmp_files/minus.gif">
 <a href="http://code.google.com/p/rtmplite/source/detail?spec=svn154&r=142">r142</a>
 by kundan10
 on Feb 5, 2012
 &nbsp; <a href="http://code.google.com/p/rtmplite/source/diff?spec=svn154&r=142&format=side&path=/trunk/rtmp.py&old_path=/trunk/rtmp.py&old=141">Diff</a>
 <br>
 <pre class="ifOpened">reverting <a href="http://code.google.com/p/rtmplite/source/detail?r=141">r141</a> since it causes
exception in setting self.rpc because
rpc exists as a function</pre>
 </div>
 
 <div class="closed" style="margin-bottom:3px;">
 <img class="ifClosed" onclick="_toggleHidden(this)" src="./rtmp_files/plus.gif">
 <img class="ifOpened" onclick="_toggleHidden(this)" src="./rtmp_files/minus.gif">
 <a href="http://code.google.com/p/rtmplite/source/detail?spec=svn154&r=141">r141</a>
 by pratnama
 on Jan 28, 2012
 &nbsp; <a href="http://code.google.com/p/rtmplite/source/diff?spec=svn154&r=141&format=side&path=/trunk/rtmp.py&old_path=/trunk/rtmp.py&old=137">Diff</a>
 <br>
 <pre class="ifOpened">force self.rpc to be Message.RPC on
NetConnection.connect() even in AMF3.
AMF3 is fully working now</pre>
 </div>
 
 <div class="closed" style="margin-bottom:3px;">
 <img class="ifClosed" onclick="_toggleHidden(this)" src="./rtmp_files/plus.gif">
 <img class="ifOpened" onclick="_toggleHidden(this)" src="./rtmp_files/minus.gif">
 <a href="http://code.google.com/p/rtmplite/source/detail?spec=svn154&r=137">r137</a>
 by kundan10
 on Jan 20, 2012
 &nbsp; <a href="http://code.google.com/p/rtmplite/source/diff?spec=svn154&r=137&format=side&path=/trunk/rtmp.py&old_path=/trunk/rtmp.py&old=121">Diff</a>
 <br>
 <pre class="ifOpened">show media flow trace only for -D.
support streambegin and define FLV in
gevent version. ignore stream name
after ?. don't include objectEncoding
in connect success if connect did not
...</pre>
 </div>
 
 
 <a href="http://code.google.com/p/rtmplite/source/list?path=/trunk/rtmp.py&start=145">All revisions of this file</a>
 </div>
 </div>
 <div class="round1"></div>
 <div class="round2"></div>
 <div class="round4"></div>
 </div>
 
 <div class="pmeta_bubble_bg" style="border:1px solid white">
 <div class="round4"></div>
 <div class="round2"></div>
 <div class="round1"></div>
 <div class="box-inner">
 <div id="fileinfo_bubble">
 <p>File info</p>
 
 <div>Size: 65812 bytes,
 1214 lines</div>
 
 <div><a href="http://rtmplite.googlecode.com/svn/trunk/rtmp.py">View raw file</a></div>
 </div>
 
 <div id="props">
 <p>File properties</p>
 <dl>
 
 <dt>svn:executable</dt>
 <dd>*</dd>
 
 <dt>svn:keywords</dt>
 <dd>Author Id Revision Date</dd>
 
 </dl>
 </div>
 
 </div>
 <div class="round1"></div>
 <div class="round2"></div>
 <div class="round4"></div>
 </div>
 </div>
 </div>


</div>

</div>
</div>

<script src="./rtmp_files/prettify.js"></script>
<script type="text/javascript">prettyPrint();</script>


<script src="./rtmp_files/source_file_scripts.js"></script>

 <script type="text/javascript" src="./rtmp_files/kibbles-1.3.3.comp.js"></script>
 <script type="text/javascript">
 var lastStop = null;
 var initialized = false;
 
 function updateCursor(next, prev) {
 if (prev && prev.element) {
 prev.element.className = 'cursor_stop cursor_hidden';
 }
 if (next && next.element) {
 next.element.className = 'cursor_stop cursor';
 lastStop = next.index;
 }
 }
 
 function pubRevealed(data) {
 updateCursorForCell(data.cellId, 'cursor_stop cursor_hidden');
 if (initialized) {
 reloadCursors();
 }
 }
 
 function draftRevealed(data) {
 updateCursorForCell(data.cellId, 'cursor_stop cursor_hidden');
 if (initialized) {
 reloadCursors();
 }
 }
 
 function draftDestroyed(data) {
 updateCursorForCell(data.cellId, 'nocursor');
 if (initialized) {
 reloadCursors();
 }
 }
 function reloadCursors() {
 kibbles.skipper.reset();
 loadCursors();
 if (lastStop != null) {
 kibbles.skipper.setCurrentStop(lastStop);
 }
 }
 // possibly the simplest way to insert any newly added comments
 // is to update the class of the corresponding cursor row,
 // then refresh the entire list of rows.
 function updateCursorForCell(cellId, className) {
 var cell = document.getElementById(cellId);
 // we have to go two rows back to find the cursor location
 var row = getPreviousElement(cell.parentNode);
 row.className = className;
 }
 // returns the previous element, ignores text nodes.
 function getPreviousElement(e) {
 var element = e.previousSibling;
 if (element.nodeType == 3) {
 element = element.previousSibling;
 }
 if (element && element.tagName) {
 return element;
 }
 }
 function loadCursors() {
 // register our elements with skipper
 var elements = CR_getElements('*', 'cursor_stop');
 var len = elements.length;
 for (var i = 0; i < len; i++) {
 var element = elements[i]; 
 element.className = 'cursor_stop cursor_hidden';
 kibbles.skipper.append(element);
 }
 }
 function toggleComments() {
 CR_toggleCommentDisplay();
 reloadCursors();
 }
 function keysOnLoadHandler() {
 // setup skipper
 kibbles.skipper.addStopListener(
 kibbles.skipper.LISTENER_TYPE.PRE, updateCursor);
 // Set the 'offset' option to return the middle of the client area
 // an option can be a static value, or a callback
 kibbles.skipper.setOption('padding_top', 50);
 // Set the 'offset' option to return the middle of the client area
 // an option can be a static value, or a callback
 kibbles.skipper.setOption('padding_bottom', 100);
 // Register our keys
 kibbles.skipper.addFwdKey("n");
 kibbles.skipper.addRevKey("p");
 kibbles.keys.addKeyPressListener(
 'u', function() { window.location = detail_url; });
 kibbles.keys.addKeyPressListener(
 'r', function() { window.location = detail_url + '#publish'; });
 
 kibbles.keys.addKeyPressListener('j', gotoNextPage);
 kibbles.keys.addKeyPressListener('k', gotoPreviousPage);
 
 
 }
 </script>
<script src="./rtmp_files/code_review_scripts.js"></script>
<script type="text/javascript">
 function showPublishInstructions() {
 var element = document.getElementById('review_instr');
 if (element) {
 element.className = 'opened';
 }
 }
 var codereviews;
 function revsOnLoadHandler() {
 // register our source container with the commenting code
 var paths = {'svn154': '/trunk/rtmp.py'}
 codereviews = CR_controller.setup(
 {"profileUrl":["/u/102069584091941751068/"],"token":"vVg-YEkpsP38PydkCFlVS-ioMOA:1335711600965","assetHostPath":"http://www.gstatic.com/codesite/ph","domainName":null,"assetVersionPath":"http://www.gstatic.com/codesite/ph/12151595242108277468","projectHomeUrl":"/p/rtmplite","relativeBaseUrl":"","projectName":"rtmplite","loggedInUserEmail":"arutyunyan.roman@gmail.com"}, '', 'svn154', paths,
 CR_BrowseIntegrationFactory);
 
 codereviews.registerActivityListener(CR_ActivityType.REVEAL_DRAFT_PLATE, showPublishInstructions);
 
 codereviews.registerActivityListener(CR_ActivityType.REVEAL_PUB_PLATE, pubRevealed);
 codereviews.registerActivityListener(CR_ActivityType.REVEAL_DRAFT_PLATE, draftRevealed);
 codereviews.registerActivityListener(CR_ActivityType.DISCARD_DRAFT_COMMENT, draftDestroyed);
 
 
 
 
 
 
 
 var initialized = true;
 reloadCursors();
 }
 window.onload = function() {keysOnLoadHandler(); revsOnLoadHandler();};

</script>
<script type="text/javascript" src="./rtmp_files/dit_scripts.js"></script>

 
 
 
 <script type="text/javascript" src="./rtmp_files/ph_core.js"></script>
 
 
 
 
 <script type="text/javascript" src="./rtmp_files/codesite_product_dictionary_ph.pack.04102009.js"></script>
</div> 
<div id="footer" dir="ltr">
 <div class="text">
 <a href="http://code.google.com/projecthosting/terms.html">Terms</a> -
 <a href="http://www.google.com/privacy.html">Privacy</a> -
 <a href="http://code.google.com/p/support/">Project Hosting Help</a>
 </div>
</div>
 <div class="hostedBy" style="margin-top: -20px;">
 <span style="vertical-align: top;">Powered by <a href="http://code.google.com/projecthosting/">Google Project Hosting</a></span>
 </div>
 
 


 
 


<div class="menuDiv instance0" id="menuDiv-projects-dropdown" style="position: absolute; display: none; top: 18px; left: 1144px; "><div class="menuCategory controls first"><hr class="menuSeparator"><a class="menuItem" style="display: block; " href="http://code.google.com/more/">Find developer products...</a><a class="menuItem" style="display: block; " href="http://code.google.com/hosting/">Find open source projects...</a></div></div></body></html>