winlin

for ExoPlayer, remove duration for live.

@@ -336,6 +336,7 @@ Remark: @@ -336,6 +336,7 @@ Remark:
336 336
337 ## History 337 ## History
338 338
  339 +* v2.0, 2015-10-28, for [ExoPlayer #828][exo #828], remove duration for live.
339 * v2.0, 2015-10-28, for [ExoPlayer #828][exo #828], add av tag in flv header. 2.0.197 340 * v2.0, 2015-10-28, for [ExoPlayer #828][exo #828], add av tag in flv header. 2.0.197
340 * v2.0, 2015-10-27, for [#512][bug #512] partical hotfix the hls pure audio. 2.0.196 341 * v2.0, 2015-10-27, for [#512][bug #512] partical hotfix the hls pure audio. 2.0.196
341 * <strong>v2.0, 2015-10-08, [2.0 alpha2(2.0.195)][r2.0a2] released. 89358 lines.</strong> 342 * <strong>v2.0, 2015-10-08, [2.0 alpha2(2.0.195)][r2.0a2] released. 89358 lines.</strong>
@@ -1400,6 +1400,11 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata @@ -1400,6 +1400,11 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata
1400 1400
1401 SrsAmf0Any* prop = NULL; 1401 SrsAmf0Any* prop = NULL;
1402 1402
  1403 + // when exists the duration, remove it to make ExoPlayer happy.
  1404 + if (metadata->metadata->get_property("duration") != NULL) {
  1405 + metadata->metadata->remove("duration");
  1406 + }
  1407 +
1403 // generate metadata info to print 1408 // generate metadata info to print
1404 std::stringstream ss; 1409 std::stringstream ss;
1405 if ((prop = metadata->metadata->ensure_property_number("width")) != NULL) { 1410 if ((prop = metadata->metadata->ensure_property_number("width")) != NULL) {
@@ -513,6 +513,24 @@ SrsAmf0Any* SrsUnSortedHashtable::ensure_property_number(string name) @@ -513,6 +513,24 @@ SrsAmf0Any* SrsUnSortedHashtable::ensure_property_number(string name)
513 return prop; 513 return prop;
514 } 514 }
515 515
  516 +void SrsUnSortedHashtable::remove(string name)
  517 +{
  518 + std::vector<SrsAmf0ObjectPropertyType>::iterator it;
  519 +
  520 + for (it = properties.begin(); it != properties.end();) {
  521 + std::string key = it->first;
  522 + SrsAmf0Any* any = it->second;
  523 +
  524 + if (key == name) {
  525 + srs_freep(any);
  526 +
  527 + it = properties.erase(it);
  528 + } else {
  529 + ++it;
  530 + }
  531 + }
  532 +}
  533 +
516 void SrsUnSortedHashtable::copy(SrsUnSortedHashtable* src) 534 void SrsUnSortedHashtable::copy(SrsUnSortedHashtable* src)
517 { 535 {
518 std::vector<SrsAmf0ObjectPropertyType>::iterator it; 536 std::vector<SrsAmf0ObjectPropertyType>::iterator it;
@@ -787,6 +805,11 @@ SrsAmf0Any* SrsAmf0Object::ensure_property_number(string name) @@ -787,6 +805,11 @@ SrsAmf0Any* SrsAmf0Object::ensure_property_number(string name)
787 return properties->ensure_property_number(name); 805 return properties->ensure_property_number(name);
788 } 806 }
789 807
  808 +void SrsAmf0Object::remove(string name)
  809 +{
  810 + properties->remove(name);
  811 +}
  812 +
790 SrsAmf0EcmaArray::SrsAmf0EcmaArray() 813 SrsAmf0EcmaArray::SrsAmf0EcmaArray()
791 { 814 {
792 _count = 0; 815 _count = 0;
@@ -405,6 +405,10 @@ public: @@ -405,6 +405,10 @@ public:
405 * @remark user should never free the returned value, copy it if needed. 405 * @remark user should never free the returned value, copy it if needed.
406 */ 406 */
407 virtual SrsAmf0Any* ensure_property_number(std::string name); 407 virtual SrsAmf0Any* ensure_property_number(std::string name);
  408 + /**
  409 + * remove the property specified by name.
  410 + */
  411 + virtual void remove(std::string name);
408 }; 412 };
409 413
410 /** 414 /**
@@ -803,6 +807,7 @@ namespace _srs_internal @@ -803,6 +807,7 @@ namespace _srs_internal
803 virtual SrsAmf0Any* get_property(std::string name); 807 virtual SrsAmf0Any* get_property(std::string name);
804 virtual SrsAmf0Any* ensure_property_string(std::string name); 808 virtual SrsAmf0Any* ensure_property_string(std::string name);
805 virtual SrsAmf0Any* ensure_property_number(std::string name); 809 virtual SrsAmf0Any* ensure_property_number(std::string name);
  810 + virtual void remove(std::string name);
806 public: 811 public:
807 virtual void copy(SrsUnSortedHashtable* src); 812 virtual void copy(SrsUnSortedHashtable* src);
808 }; 813 };