阿里云直播推流和拉流地址获取方式

 

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; 

        }

猜你喜欢

转载自www.cnblogs.com/dsjbk/p/12538940.html