winlin

for bug #87, response the server SrsId to flash.

@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 ////////////////////////////////////////////////////////////////////////////////// 3 //////////////////////////////////////////////////////////////////////////////////
4 4
5 // to query the swf anti cache. 5 // to query the swf anti cache.
6 -function srs_get_version_code() { return "1.20"; } 6 +function srs_get_version_code() { return "1.21"; }
7 7
8 /** 8 /**
9 * player specified size. 9 * player specified size.
@@ -132,21 +132,41 @@ package @@ -132,21 +132,41 @@ package
132 elapTimer.restart(); 132 elapTimer.restart();
133 } 133 }
134 } 134 }
  135 +
  136 + // srs infos
  137 + private var srs_server:String = null;
  138 + private var srs_primary_authors:String = null;
  139 + private var srs_id:String = null;
  140 + private function update_context_items():void {
  141 + // for context menu
  142 + var customItems:Array = [new ContextMenuItem("SrsPlayer")];
  143 + if (srs_server != null) {
  144 + customItems.push(new ContextMenuItem("Server: " + srs_server));
  145 + }
  146 + if (srs_primary_authors != null) {
  147 + customItems.push(new ContextMenuItem("PrimaryAuthors: " + srs_primary_authors));
  148 + }
  149 + if (srs_id != null) {
  150 + customItems.push(new ContextMenuItem("SrsId: " + srs_id));
  151 + }
  152 + contextMenu.customItems = customItems;
  153 + }
135 154
136 // get NetConnection NetStatusEvent 155 // get NetConnection NetStatusEvent
137 public function onStatus(evt:NetStatusEvent) : void{ 156 public function onStatus(evt:NetStatusEvent) : void{
138 trace(evt.info.code); 157 trace(evt.info.code);
139 158
140 if (evt.info.hasOwnProperty("data") && evt.info.data) { 159 if (evt.info.hasOwnProperty("data") && evt.info.data) {
141 - // for context menu  
142 - var customItems:Array = [new ContextMenuItem("SrsPlayer")];  
143 if (evt.info.data.hasOwnProperty("srs_server")) { 160 if (evt.info.data.hasOwnProperty("srs_server")) {
144 - customItems.push(new ContextMenuItem("Server: " + evt.info.data.srs_server)); 161 + srs_server = evt.info.data.srs_server;
145 } 162 }
146 if (evt.info.data.hasOwnProperty("srs_primary_authors")) { 163 if (evt.info.data.hasOwnProperty("srs_primary_authors")) {
147 - customItems.push(new ContextMenuItem("PrimaryAuthors: " + evt.info.data.srs_primary_authors)); 164 + srs_primary_authors = evt.info.data.srs_primary_authors;
  165 + }
  166 + if (evt.info.data.hasOwnProperty("srs_id")) {
  167 + srs_id = evt.info.data.srs_id;
148 } 168 }
149 - contextMenu.customItems = customItems; 169 + update_context_items();
150 } 170 }
151 171
152 switch(evt.info.code){ 172 switch(evt.info.code){
@@ -143,29 +143,17 @@ package @@ -143,29 +143,17 @@ package
143 private function system_on_metadata(metadata:Object):void { 143 private function system_on_metadata(metadata:Object):void {
144 this.media_metadata = metadata; 144 this.media_metadata = metadata;
145 145
146 - if (metadata.hasOwnProperty("server")) {  
147 - // for context menu  
148 - var customItems:Array = [new ContextMenuItem("SrsPlayer")];  
149 - if (metadata.hasOwnProperty("server")) {  
150 - customItems.push(new ContextMenuItem("Server: " + metadata.server));  
151 - }  
152 - if (metadata.hasOwnProperty("contributor")) {  
153 - customItems.push(new ContextMenuItem("Contributor: " + metadata.contributor));  
154 - }  
155 - contextMenu.customItems = customItems;  
156 - }  
157 -  
158 // for js. 146 // for js.
159 var obj:Object = __get_video_size_object(); 147 var obj:Object = __get_video_size_object();
160 148
161 obj.server = 'srs'; 149 obj.server = 'srs';
162 obj.contributor = 'winlin'; 150 obj.contributor = 'winlin';
163 151
164 - if (metadata.hasOwnProperty("server")) {  
165 - obj.server = metadata.server; 152 + if (srs_server != null) {
  153 + obj.server = srs_server;
166 } 154 }
167 - if (metadata.hasOwnProperty("contributor")) {  
168 - obj.contributor = metadata.contributor; 155 + if (srs_primary_authors != null) {
  156 + obj.contributor = srs_primary_authors;
169 } 157 }
170 158
171 var code:int = flash.external.ExternalInterface.call(js_on_player_metadata, js_id, obj); 159 var code:int = flash.external.ExternalInterface.call(js_on_player_metadata, js_id, obj);
@@ -277,6 +265,25 @@ package @@ -277,6 +265,25 @@ package
277 } 265 }
278 } 266 }
279 267
  268 + // srs infos
  269 + private var srs_server:String = null;
  270 + private var srs_primary_authors:String = null;
  271 + private var srs_id:String = null;
  272 + private function update_context_items():void {
  273 + // for context menu
  274 + var customItems:Array = [new ContextMenuItem("SrsPlayer")];
  275 + if (srs_server != null) {
  276 + customItems.push(new ContextMenuItem("Server: " + srs_server));
  277 + }
  278 + if (srs_primary_authors != null) {
  279 + customItems.push(new ContextMenuItem("PrimaryAuthors: " + srs_primary_authors));
  280 + }
  281 + if (srs_id != null) {
  282 + customItems.push(new ContextMenuItem("SrsId: " + srs_id));
  283 + }
  284 + contextMenu.customItems = customItems;
  285 + }
  286 +
280 /** 287 /**
281 * function for js to call: to play the stream. stop then play. 288 * function for js to call: to play the stream. stop then play.
282 * @param url, the rtmp/http url to play. 289 * @param url, the rtmp/http url to play.
@@ -300,15 +307,16 @@ package @@ -300,15 +307,16 @@ package
300 trace ("NetConnection: code=" + evt.info.code); 307 trace ("NetConnection: code=" + evt.info.code);
301 308
302 if (evt.info.hasOwnProperty("data") && evt.info.data) { 309 if (evt.info.hasOwnProperty("data") && evt.info.data) {
303 - // for context menu  
304 - var customItems:Array = [new ContextMenuItem("SrsPlayer")];  
305 if (evt.info.data.hasOwnProperty("srs_server")) { 310 if (evt.info.data.hasOwnProperty("srs_server")) {
306 - customItems.push(new ContextMenuItem("Server: " + evt.info.data.srs_server)); 311 + srs_server = evt.info.data.srs_server;
307 } 312 }
308 if (evt.info.data.hasOwnProperty("srs_primary_authors")) { 313 if (evt.info.data.hasOwnProperty("srs_primary_authors")) {
309 - customItems.push(new ContextMenuItem("PrimaryAuthors: " + evt.info.data.srs_primary_authors)); 314 + srs_primary_authors = evt.info.data.srs_primary_authors;
  315 + }
  316 + if (evt.info.data.hasOwnProperty("srs_id")) {
  317 + srs_id = evt.info.data.srs_id;
310 } 318 }
311 - contextMenu.customItems = customItems; 319 + update_context_items();
312 } 320 }
313 321
314 // TODO: FIXME: failed event. 322 // TODO: FIXME: failed event.
@@ -134,6 +134,25 @@ package @@ -134,6 +134,25 @@ package
134 flash.external.ExternalInterface.call(this.js_on_publisher_warn, this.js_id, code); 134 flash.external.ExternalInterface.call(this.js_on_publisher_warn, this.js_id, code);
135 } 135 }
136 136
  137 + // srs infos
  138 + private var srs_server:String = null;
  139 + private var srs_primary_authors:String = null;
  140 + private var srs_id:String = null;
  141 + private function update_context_items():void {
  142 + // for context menu
  143 + var customItems:Array = [new ContextMenuItem("SrsPlayer")];
  144 + if (srs_server != null) {
  145 + customItems.push(new ContextMenuItem("Server: " + srs_server));
  146 + }
  147 + if (srs_primary_authors != null) {
  148 + customItems.push(new ContextMenuItem("PrimaryAuthors: " + srs_primary_authors));
  149 + }
  150 + if (srs_id != null) {
  151 + customItems.push(new ContextMenuItem("SrsId: " + srs_id));
  152 + }
  153 + contextMenu.customItems = customItems;
  154 + }
  155 +
137 /** 156 /**
138 * publish stream to server. 157 * publish stream to server.
139 * @param url a string indicates the rtmp url to publish. 158 * @param url a string indicates the rtmp url to publish.
@@ -187,15 +206,16 @@ package @@ -187,15 +206,16 @@ package
187 trace ("NetConnection: code=" + evt.info.code); 206 trace ("NetConnection: code=" + evt.info.code);
188 207
189 if (evt.info.hasOwnProperty("data") && evt.info.data) { 208 if (evt.info.hasOwnProperty("data") && evt.info.data) {
190 - // for context menu  
191 - var customItems:Array = [new ContextMenuItem("SrsPlayer")];  
192 if (evt.info.data.hasOwnProperty("srs_server")) { 209 if (evt.info.data.hasOwnProperty("srs_server")) {
193 - customItems.push(new ContextMenuItem("Server: " + evt.info.data.srs_server)); 210 + srs_server = evt.info.data.srs_server;
194 } 211 }
195 if (evt.info.data.hasOwnProperty("srs_primary_authors")) { 212 if (evt.info.data.hasOwnProperty("srs_primary_authors")) {
196 - customItems.push(new ContextMenuItem("PrimaryAuthors: " + evt.info.data.srs_primary_authors)); 213 + srs_primary_authors = evt.info.data.srs_primary_authors;
  214 + }
  215 + if (evt.info.data.hasOwnProperty("srs_id")) {
  216 + srs_id = evt.info.data.srs_id;
197 } 217 }
198 - contextMenu.customItems = customItems; 218 + update_context_items();
199 } 219 }
200 220
201 if (evt.info.code == "NetConnection.Connect.Closed") { 221 if (evt.info.code == "NetConnection.Connect.Closed") {
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR "0" 32 #define VERSION_MAJOR "0"
33 #define VERSION_MINOR "9" 33 #define VERSION_MINOR "9"
34 -#define VERSION_REVISION "117" 34 +#define VERSION_REVISION "118"
35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION 35 #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
36 // server info. 36 // server info.
37 #define RTMP_SIG_SRS_KEY "SRS" 37 #define RTMP_SIG_SRS_KEY "SRS"
@@ -866,6 +866,8 @@ int SrsRtmpServer::response_connect_app(SrsRequest *req, const char* server_ip) @@ -866,6 +866,8 @@ int SrsRtmpServer::response_connect_app(SrsRequest *req, const char* server_ip)
866 if (server_ip) { 866 if (server_ip) {
867 data->set("srs_server_ip", SrsAmf0Any::str(server_ip)); 867 data->set("srs_server_ip", SrsAmf0Any::str(server_ip));
868 } 868 }
  869 + // for edge to directly get the id of client.
  870 + data->set("srs_id", SrsAmf0Any::number(_srs_context->get_id()));
869 871
870 if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) { 872 if ((ret = protocol->send_and_free_packet(pkt, 0)) != ERROR_SUCCESS) {
871 srs_error("send connect app response message failed. ret=%d", ret); 873 srs_error("send connect app response message failed. ret=%d", ret);