阿里雲直播推流和拉流地址獲取方式


 

1.生成推流地址

string AppName = "AppName";//自定義

string StreamName = "StreamName";//自定義

int time = (int)DateTime.Now.Subtract(DateTime.Parse("1970-1-1")).TotalSeconds + 1800;//時間戳1800秒有效時間30分鍾 

string key = "推流鑒權";

string strpush = "/" + AppName + "/" + StreamName + "-" + time + "-0-0-" + key;

string pushurl = "rtmp://推流地址/" + AppName + "/" + StreamName + "?auth_key=" + time + "-0-0-" + MD5(strpush);

2.生成拉流地址

         /// <summary>

        /// 直播地址

        /// </summary>   

        /// <param name="StreamName">自定義</param>     

        /// <returns></returns>

           public static string GetZhuanMaUrl(string StreamName)

        {

string AppName = "AppName";

int time = (int)DateTime.Now.Subtract(DateTime.Parse("1970-1-1")).TotalSeconds + 86400;

string liveKey = "拉流鑒權";

string liveDomain = "播放地址";

///appName/streamName-timestamp-rand-uid-key

string strviewrtmp1 = "/" + AppName + "/" + StreamName + "-" + time + "-0-0-" + liveKey;

string rtmpurl1 = "rtmp://" + liveDomain + "/" + AppName + "/" + StreamName + "?auth_key=" + time + "-0-0-" + MD5(strviewrtmp1); 

return rtmpurl1; 

        }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM