问题描述

目前为了能够方便开发者,我们将EasyDarwin中的RTSP认证过程直接忽略过了,如果要开启认证的方式,我们可以在代码中打开:

        case kRoutingRequest:
{
// Invoke router modules
numModules = QTSServerInterface::GetNumModulesInRole(QTSSModule::kRTSPRouteRole);
{
// Manipulation of the RTPSession from the point of view of
// a module is guaranteed to be atomic by the API.
Assert(fRTPSession != NULL);
OSMutexLocker locker(fRTPSession->GetSessionMutex()); for (; (fCurrentModule < numModules) && ((!fRequest->HasResponseBeenSent()) || fModuleState.eventRequested); fCurrentModule++)
{
fModuleState.eventRequested = false;
fModuleState.idleTime = 0;
if (fModuleState.globalLockRequested)
{
fModuleState.globalLockRequested = false;
fModuleState.isGlobalLocked = true;
}
theModule = QTSServerInterface::GetModule(QTSSModule::kRTSPRouteRole, fCurrentModule);
(void)theModule->CallDispatch(QTSS_RTSPRoute_Role, &fRoleParams);
fModuleState.isGlobalLocked = false; if (fModuleState.globalLockRequested) // call this request back locked
return this->CallLocked(); // If this module has requested an event, return and wait for the event to transpire
if (fModuleState.eventRequested)
{
this->ForceSameThread(); // We are holding mutexes, so we need to force
// the same thread to be used for next Run()
return fModuleState.idleTime; // If the module has requested idle time...
}
}
}
fCurrentModule = 0; // SetupAuthLocalPath must happen after kRoutingRequest and before kAuthenticatingRequest
// placed here so that if the state is shifted to kPostProcessingRequest from a response being sent
// then the AuthLocalPath will still be set.
fRequest->SetupAuthLocalPath(); if (fRequest->HasResponseBeenSent())
{
fState = kPostProcessingRequest;
break;
} //!!! 这里打开对RTSPSession进行授权认证的过程 !!!
if (fRequest->SkipAuthorization())
{
// Skip the authentication and authorization states // The foll. normally gets executed at the end of the authorization state
// Prepare for kPreprocessingRequest state.
fState = kPreprocessingRequest; if (fRequest->GetMethod() == qtssSetupMethod)
// Make sure to erase the session ID stored in the request at this point.
// If we fail to do so, this same session would be used if another
// SETUP was issued on this same TCP connection.
fLastRTPSessionIDPtr.Len = 0;
else if (fLastRTPSessionIDPtr.Len == 0)
fLastRTPSessionIDPtr.Len = ::strlen(fLastRTPSessionIDPtr.Ptr); break;
}
else
fState = kAuthenticatingRequest;
}

这里将kAuthenticatingRequest流程打开就能够进行RTSP认证的验证过程了,那么还有一种Token验证的方式,这种方法就类似于RTMP里面的认证方式,在流名称后面增加认证的Token串作为请求URL的QueryString发送给服务器进行动态认证,那么这种方式,我们可以在RTSPSession::SetupRequest中进行Token的相关过滤:

void RTSPSession::SetupRequest()
{
// First parse the request
QTSS_Error theErr = fRequest->Parse();
if (theErr != QTSS_NoErr)
return; // 对RTSPRequest进行Token解析
StrPtrLen *token = fRequest->GetValue(qtssRTSPReqQueryString);
//TODO::对Token进行自定义验证,失败返回401等相应错误码
// // let's also refresh RTP session timeout so that it's kept alive in sync with the RTSP session.
//
// Attempt to find the RTP session for this request.
OSRefTable* theMap = QTSServerInterface::GetServer()->GetRTPSessionMap();
theErr = this->FindRTPSession(theMap);

EasyDarwin RTSP认证方式

基于配置文件中用户名/密码认证的方法可参考:EasyDarwin开源流媒体服务器支持basic基本认证和digest摘要认证解析

RTSP动态认证的方式可以参考博客《EasyDarwin开源流媒体服务器支持basic基本认证和digest摘要自定义认证

EasyDarwin Token认证方式

我们可以自定义一个EasyDarwin的Module,再在上述中的RTSPSession::SetupRequest中,将token以参数的形式传递给Module进行认证处理,其处理流程可以模仿《EasyDarwin开源流媒体服务器支持basic基本认证和digest摘要自定义认证》中的流程进行;

Github

EasyDarwin开源流媒体服务器:https://github.com/EasyDarwin/EasyDarwin

获取更多信息

邮件:support@easydarwin.org

WEB:www.EasyDarwin.org

Copyright © EasyDarwin.org 2012-2016

EasyDarwin实现RTSP播放动态认证的两种方式:Basic/Digest & Token的更多相关文章

  1. EF动态linq的两种方式

    网上收集的资源  我怕遗忘就在自己博客记录下,有些我忘记原文地址了请见谅 这个链接的动态sql方式是 where("c=>c.id==id") https://weblogs ...

  2. 动态代理的两种方式,以及区别(静态代理、JDK与CGLIB动态代理、AOP+IoC)

    Spring学习总结(二)——静态代理.JDK与CGLIB动态代理.AOP+IoC   目录 一.为什么需要代理模式 二.静态代理 三.动态代理,使用JDK内置的Proxy实现 四.动态代理,使用cg ...

  3. 【Unity】Unity中资源动态载入的两种方式之AssetsBundle

    首先要说的是,我们的project中有2个脚本.各自是: Build(编辑器类脚本.无需挂载到不论什么物体).可是必需要把Build脚本放到Editor目录中 Load脚本,挂载到摄像机上<pr ...

  4. Java实现动态代理的两种方式

    http://m.blog.csdn.net/article/details?id=49738887

  5. C#调用C++ DLL动态库的两种方式

    第一种方式:C++导出函数, c#dllimport 的方式 在很多地方都看到过,如[dllimport "user32.dll"]这种代码,调用windows API,就是通过这 ...

  6. 【转】Unity3D研究院之两种方式播放游戏视频

    http://www.xuanyusong.com/archives/1019   Unity3D中播放游戏视频的方式有两种,第一种是在游戏对象中播放,就好比在游戏世界中创建一个Plane面对象,摄像 ...

  7. SpringBoot中使用Spring Data Jpa 实现简单的动态查询的两种方法

    软件152 尹以操 首先谢谢大佬的简书文章:http://www.jianshu.com/p/45ad65690e33# 这篇文章中讲的是spring中使用spring data jpa,使用了xml ...

  8. C#动态调用WCF接口,两种方式任你选。

    写在前面 接触WCF还是它在最初诞生之处,一个分布式应用的巨作. 从开始接触到现在断断续续,真正使用的项目少之又少,更谈不上深入WCF内部实现机制和原理去研究,最近自己做一个项目时用到了WCF. 从这 ...

  9. Cocos2d-x学习笔记(五岁以下儿童) 精灵两种方式播放动画

     这几天在看控件类,临时没有想好实际运用的方向.单纯的创建网上已经有非常多这方面的样例,我就不写了.接下来是学习精灵类.精灵类若是单独学习也是非常easy.于是我加了一些有关动画方面的知识点与精灵 ...

随机推荐

  1. FZOJ Problem 2150 Fire Game

                                                                                                        ...

  2. FZOJ Problem 2103 Bin & Jing in wonderland

                                                                                                        ...

  3. POJ3928 Ping pong

      Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %lld & %llu Description N(3<= ...

  4. 【CF1028C】Rectangles(线段树)

    题意: n<=1e5,abs(x[i]),abs(y[i]<=1e9 思路:这是正解 离散后线段树强打,数据结构越学越傻 #include<cstdio> #include&l ...

  5. C#:判断当前线程所处状态&委托

    1.线程状态ThreadState 在C#中,线程对象Thread使用ThreadState属性指示线程状态,它是带Flags特性的枚举类型对象. ThreadState 为线程定义了一组所有可能的执 ...

  6. 线程间通过PostMessage通信

    1.查看TMS项目中的相关实例 ::PostMessage(hWnd, WM_USER_MSG_REFRESH_UI, (WPARAM)UMP_REFRESH_MEMBER_INFO, 0); 参考文 ...

  7. Scrapy学习-14-验证码识别

    3种实现方案   1. 编码实现 tesseract-ocr 谷歌开源的识别工具,自己实现代码编码,投入精力大,回馈低.且平台验证码更换周期短,编好的代码容易失效 2. 在线打码 在线平台提供,识别率 ...

  8. Windwos2008如何关闭IE增强的安全配置

    如题 方法:

  9. AC日记——【模板】线段树 2 洛谷 P3373

    P3373 [模板]线段树 2387通过1.8K提交标签难度 提高+/省选- 提交 讨论 题解 最新讨论 更多讨论 2333最后三个点卡常数.迷之RE感觉这题很迷啊好像一共三组测试数据.友情提示:开l ...

  10. 可能是全网最详细的express--middleware

    写在前面 hello,小伙伴们,我是你们的pubdreamcc,本篇博文出至于我的GitHub仓库node学习教程资料,欢迎小伙伴们点赞和star,你们的点赞是我持续更新的动力. GitHub仓库地址 ...