| 2816 | } |
| 2817 | |
| 2818 | void ParseRtmpURL(const butil::StringPiece& rtmp_url_in, |
| 2819 | butil::StringPiece* host, |
| 2820 | butil::StringPiece* vhost, |
| 2821 | butil::StringPiece* port, |
| 2822 | butil::StringPiece* app, |
| 2823 | butil::StringPiece* stream_name) { |
| 2824 | if (stream_name) { |
| 2825 | stream_name->clear(); |
| 2826 | } |
| 2827 | butil::StringPiece rtmp_url = RemoveRtmpPrefix(rtmp_url_in); |
| 2828 | size_t slash1_pos = rtmp_url.find_first_of('/'); |
| 2829 | if (slash1_pos == butil::StringPiece::npos) { |
| 2830 | if (host || port) { |
| 2831 | ParseRtmpHostAndPort(rtmp_url, host, port); |
| 2832 | } |
| 2833 | if (app) { |
| 2834 | app->clear(); |
| 2835 | } |
| 2836 | return; |
| 2837 | } |
| 2838 | if (host || port) { |
| 2839 | ParseRtmpHostAndPort(rtmp_url.substr(0, slash1_pos), host, port); |
| 2840 | } |
| 2841 | // Remove duplicated slashes. |
| 2842 | for (++slash1_pos; slash1_pos < rtmp_url.size() && |
| 2843 | rtmp_url[slash1_pos] == '/'; ++slash1_pos); |
| 2844 | rtmp_url.remove_prefix(slash1_pos); |
| 2845 | size_t slash2_pos = rtmp_url.find_first_of('/'); |
| 2846 | if (slash2_pos == butil::StringPiece::npos) { |
| 2847 | return SplitVHostFromApp(rtmp_url, app, vhost); |
| 2848 | } |
| 2849 | SplitVHostFromApp(rtmp_url.substr(0, slash2_pos), app, vhost); |
| 2850 | if (stream_name != NULL) { |
| 2851 | // Remove duplicated slashes. |
| 2852 | for (++slash2_pos; slash2_pos < rtmp_url.size() && |
| 2853 | rtmp_url[slash2_pos] == '/'; ++slash2_pos); |
| 2854 | rtmp_url.remove_prefix(slash2_pos); |
| 2855 | *stream_name = rtmp_url; |
| 2856 | } |
| 2857 | } |
| 2858 | |
| 2859 | std::string MakeRtmpURL(const butil::StringPiece& host, |
| 2860 | const butil::StringPiece& port, |