问题描述

目前为了能够方便开发者,我们将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. SharePoint 2013 SSO-Secure Store Service在实际案例中的应用

    文章目录: Secure Store Service介绍 Secure Store Service部署 Secure Store Service应用 之前有一篇博客讲到使用EMSManagedAPI操 ...

  2. Atcoder CODE FESTIVAL 2017 qual B C - 3 Steps 二分图

    题目链接 题意 给定一个无向图,\(n\)个点,\(m\)条边(\(n,m\leq 1e5\)). 重复如下操作: 选择相异的两点u,v满足从点u出发走三条边恰好能到达点v.在这样的u,v点对之间添一 ...

  3. Hibernate游记——装备篇《三》(连接池的使用)

    这里介绍几种最常见的连接池配置: [说明:在hibernate3.0中,已经不再支持dbcp了,hibernate的作者在hibernate.org中,明确指出在实践中发现dbcp有BUG,在某些种情 ...

  4. 根据ipnut的maxlength实时提示输入的字符长度

    $(function(){ $("body").on("focus","input,textarea", function() { if(! ...

  5. BZOJ 4326 NOIP2015 运输计划(二分答案 + 树上差分思想)

    题目链接  BZOJ4326 这个程序在洛谷上TLE了……惨遭卡常 在NOIP赛场上估计只能拿到95分吧= = 把边权转化成点权 首先求出每一条路径的长度 考虑二分答案,$check(now)$ 对于 ...

  6. OS | 冯诺伊曼体系和哈佛体系

    冯·诺伊曼结构(von Neumann architecture),也称普林斯顿结构,是一种将程序指令存储器和数据存储器合并在一起的计算机设计概念结构.本词描述的是一种实现通用图灵机的计算设备,以及一 ...

  7. Mybatis Generator插件和PageHelper使用

    最近,开始接触web项目开发,项目使用springboot和mybatis,以前一直以为开发过程中实体类,mybatis的xml文件都需要自己手动的去创建. 同事推荐说Mybatis Generato ...

  8. 布斯(Steve Jobs)在斯坦福大学的演讲稿,中英文对照版

    2005年6月14日,苹果CEO史蒂夫·乔布斯(Steve Jobs)在他的母校斯坦福大学的毕业典礼发表了著名的演讲,关于这段演讲,你会看到N多人的推荐(比如同样喜欢在大学演讲的李开复先生).此前曾经 ...

  9. session转载

    sessionid是一个会话的key,浏览器第一次访问服务器会在服务器端生成一个session,有一个sessionid和它对应.tomcat生成的sessionid叫做jsessionid. ses ...

  10. fastscript增加三方控件之二

    fastscript增加三方控件之二 unit fs_BsDataSet; interface {$i fs.inc} uses SysUtils, Classes, fs_iinterpreter, ...