正在显示
3 个修改的文件
包含
33 行增加
和
0 行删除
| @@ -1407,6 +1407,11 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | @@ -1407,6 +1407,11 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | ||
| 1407 | 1407 | ||
| 1408 | SrsAmf0Any* prop = NULL; | 1408 | SrsAmf0Any* prop = NULL; |
| 1409 | 1409 | ||
| 1410 | + // when exists the duration, remove it to make ExoPlayer happy. | ||
| 1411 | + if (metadata->metadata->get_property("duration") != NULL) { | ||
| 1412 | + metadata->metadata->remove("duration"); | ||
| 1413 | + } | ||
| 1414 | + | ||
| 1410 | // generate metadata info to print | 1415 | // generate metadata info to print |
| 1411 | std::stringstream ss; | 1416 | std::stringstream ss; |
| 1412 | if ((prop = metadata->metadata->ensure_property_number("width")) != NULL) { | 1417 | if ((prop = metadata->metadata->ensure_property_number("width")) != NULL) { |
| @@ -561,6 +561,24 @@ SrsAmf0Any* SrsUnSortedHashtable::ensure_property_number(string name) | @@ -561,6 +561,24 @@ SrsAmf0Any* SrsUnSortedHashtable::ensure_property_number(string name) | ||
| 561 | return prop; | 561 | return prop; |
| 562 | } | 562 | } |
| 563 | 563 | ||
| 564 | +void SrsUnSortedHashtable::remove(string name) | ||
| 565 | +{ | ||
| 566 | + std::vector<SrsAmf0ObjectPropertyType>::iterator it; | ||
| 567 | + | ||
| 568 | + for (it = properties.begin(); it != properties.end();) { | ||
| 569 | + std::string key = it->first; | ||
| 570 | + SrsAmf0Any* any = it->second; | ||
| 571 | + | ||
| 572 | + if (key == name) { | ||
| 573 | + srs_freep(any); | ||
| 574 | + | ||
| 575 | + it = properties.erase(it); | ||
| 576 | + } else { | ||
| 577 | + ++it; | ||
| 578 | + } | ||
| 579 | + } | ||
| 580 | +} | ||
| 581 | + | ||
| 564 | void SrsUnSortedHashtable::copy(SrsUnSortedHashtable* src) | 582 | void SrsUnSortedHashtable::copy(SrsUnSortedHashtable* src) |
| 565 | { | 583 | { |
| 566 | std::vector<SrsAmf0ObjectPropertyType>::iterator it; | 584 | std::vector<SrsAmf0ObjectPropertyType>::iterator it; |
| @@ -849,6 +867,11 @@ SrsAmf0Any* SrsAmf0Object::ensure_property_number(string name) | @@ -849,6 +867,11 @@ SrsAmf0Any* SrsAmf0Object::ensure_property_number(string name) | ||
| 849 | return properties->ensure_property_number(name); | 867 | return properties->ensure_property_number(name); |
| 850 | } | 868 | } |
| 851 | 869 | ||
| 870 | +void SrsAmf0Object::remove(string name) | ||
| 871 | +{ | ||
| 872 | + properties->remove(name); | ||
| 873 | +} | ||
| 874 | + | ||
| 852 | SrsAmf0EcmaArray::SrsAmf0EcmaArray() | 875 | SrsAmf0EcmaArray::SrsAmf0EcmaArray() |
| 853 | { | 876 | { |
| 854 | _count = 0; | 877 | _count = 0; |
| @@ -414,6 +414,10 @@ public: | @@ -414,6 +414,10 @@ public: | ||
| 414 | * @remark user should never free the returned value, copy it if needed. | 414 | * @remark user should never free the returned value, copy it if needed. |
| 415 | */ | 415 | */ |
| 416 | virtual SrsAmf0Any* ensure_property_number(std::string name); | 416 | virtual SrsAmf0Any* ensure_property_number(std::string name); |
| 417 | + /** | ||
| 418 | + * remove the property specified by name. | ||
| 419 | + */ | ||
| 420 | + virtual void remove(std::string name); | ||
| 417 | }; | 421 | }; |
| 418 | 422 | ||
| 419 | /** | 423 | /** |
| @@ -820,6 +824,7 @@ namespace _srs_internal | @@ -820,6 +824,7 @@ namespace _srs_internal | ||
| 820 | virtual SrsAmf0Any* get_property(std::string name); | 824 | virtual SrsAmf0Any* get_property(std::string name); |
| 821 | virtual SrsAmf0Any* ensure_property_string(std::string name); | 825 | virtual SrsAmf0Any* ensure_property_string(std::string name); |
| 822 | virtual SrsAmf0Any* ensure_property_number(std::string name); | 826 | virtual SrsAmf0Any* ensure_property_number(std::string name); |
| 827 | + virtual void remove(std::string name); | ||
| 823 | public: | 828 | public: |
| 824 | virtual void copy(SrsUnSortedHashtable* src); | 829 | virtual void copy(SrsUnSortedHashtable* src); |
| 825 | }; | 830 | }; |
-
请 注册 或 登录 后发表评论