Skip to content

Add DarwinStreamingSrvr6.0.3-Source #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added .DS_Store
Binary file not shown.
325 changes: 244 additions & 81 deletions APICommonCode/QTAccessFile.cpp

Large diffs are not rendered by default.

54 changes: 44 additions & 10 deletions APICommonCode/QTAccessFile.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
Expand Down Expand Up @@ -37,6 +37,8 @@
#include "QTSS.h"
#include "StrPtrLen.h"
#include "OSHeaders.h"
#include "StringParser.h"
#include "OSMutex.h"

class QTAccessFile
{
Expand All @@ -51,6 +53,16 @@ class QTAccessFile
// GetGroupsArrayCopy allocates outGroupCharPtrArray. Caller must "delete [] outGroupCharPtrArray" when done.
static char* GetAccessFile_Copy( const char* movieRootDir, const char* dirPath);

//over ride these in a sub class
virtual Bool16 HaveUser(char *userName, void* extraDataPtr);
virtual Bool16 HaveGroups( char** groupArray, UInt32 numGroups, void* extraDataPtr);
virtual Bool16 HaveRealm( char *userName, StrPtrLen* ioRealmNameStr, void *extraData );
virtual Bool16 TestUser(StrPtrLen* accessUser, char *userName,void *extraDataPtr );
virtual Bool16 TestGroup( StrPtrLen* accessGroup, char *userName, char**groupArray, UInt32 numGroups, void *extraDataPtr);
virtual Bool16 TestExtraData( StrPtrLen* wordPtr, StringParser* lineParserPtr, void* extraDataPtr);
virtual void GetRealm(StrPtrLen* accessRealm, StrPtrLen* ioRealmNameStr, char *userName,void *extraDataPtr );
virtual Bool16 ValidUser(char* userName, void* extraDataPtr) { return false; };

//AccessAllowed
//
// This routine is used to get the Realm to send back to a user and to check if a user has access
Expand All @@ -60,24 +72,46 @@ class QTAccessFile
// To get a returned ioRealmNameStr value the ioRealmNameStr and ioRealmNameStr->Ptr must be non-NULL
// valid pointers. The ioRealmNameStr.Len should be set to the ioRealmNameStr->Ptr's allocated len.
// numGroups: The number of groups in the groupArray. Use GetGroupsArrayCopy to create the groupArray.
static Bool16 AccessAllowed ( char *userName, char**groupArray, UInt32 numGroups,
StrPtrLen *accessFileBufPtr,QTSS_ActionFlags inFlags,StrPtrLen* ioRealmNameStr
Bool16 AccessAllowed ( char *userName, char**groupArray, UInt32 numGroups,
StrPtrLen *accessFileBufPtr,QTSS_ActionFlags inFlags,StrPtrLen* ioRealmNameStr,
Bool16* outAllowAnyUserPtr,
void *extraDataPtr = NULL
);

static void SetAccessFileName(const char *inQTAccessFileName); //makes a copy and stores it
static char* GetAccessFileName() { return sQTAccessFileName; }; // a reference. Don't delete!

// allocates memory for outUsersFilePath and outGroupsFilePath - remember to delete
// returns the auth scheme
static QTSS_AuthScheme FindUsersAndGroupsFilesAndAuthScheme(char* inAccessFilePath, QTSS_ActionFlags inAction, char** outUsersFilePath, char** outGroupsFilePath);
// allocates memory for outUsersFilePath and outGroupsFilePath - remember to delete
// returns the auth scheme
static QTSS_AuthScheme FindUsersAndGroupsFilesAndAuthScheme(char* inAccessFilePath, QTSS_ActionFlags inAction, char** outUsersFilePath, char** outGroupsFilePath);

static QTSS_Error AuthorizeRequest(QTSS_StandardRTSP_Params* inParams, Bool16 allowNoAccessFiles, QTSS_ActionFlags noAction, QTSS_ActionFlags authorizeAction);

QTSS_Error AuthorizeRequest(QTSS_StandardRTSP_Params* inParams, Bool16 allowNoAccessFiles, QTSS_ActionFlags noAction, QTSS_ActionFlags authorizeAction, Bool16 *outAuthorizedPtr, Bool16* outAllowAnyUserPtr = NULL);
virtual ~QTAccessFile() {};

private:
static char* sQTAccessFileName; // managed by the QTAccess module
static Bool16 sAllocatedName;
static OSMutex* sAccessFileMutex;
static char* sAccessValidUser;
static char* sAccessAnyUser;


};

class DSAccessFile : public QTAccessFile
{
public:
virtual ~DSAccessFile() {}
virtual Bool16 HaveGroups( char** groupArray, UInt32 numGroups, void* extraDataPtr) { return true; }
virtual Bool16 TestGroup( StrPtrLen* accessGroup, char *userName, char**groupArray, UInt32 numGroups, void *extraDataPtr)
{ StrPtrLenDel deleter( accessGroup->GetAsCString() );
return this->CheckGroupMembership(userName, deleter.Ptr );
}
virtual Bool16 ValidUser(char* userName, void* extraDataPtr);
bool CheckGroupMembership(const char* inUsername, const char* inGroupName);

};


#endif //_QT_ACCESS_FILE_H_

128 changes: 128 additions & 0 deletions APICommonCode/QTSS3GPPModuleUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
/*
File: QTSS3GPPModuleUtils.cpp

Contains: Implements utility routines defined in QTSS3GPPModuleUtils.h.

*/

#include "QTSS3GPPModuleUtils.h"
#include "QTSSModuleUtils.h"
#include "QTSS_Private.h"

#include "StrPtrLen.h"
#include "OSArrayObjectDeleter.h"
#include "OSMemory.h"
#include "MyAssert.h"
#include "StringFormatter.h"
#include "ResizeableStringFormatter.h"
#include "StringParser.h"
#include "SafeStdLib.h"


QTSS_TextMessagesObject QTSS3GPPModuleUtils::sMessages = NULL;
QTSS_ServerObject QTSS3GPPModuleUtils::sServer = NULL;
QTSS_PrefsObject QTSS3GPPModuleUtils::sServerPrefs = NULL;
QTSS_StreamRef QTSS3GPPModuleUtils::sErrorLog = NULL;
StrPtrLen QTSS3GPPModuleUtils::s3gppBitRateAdaptationSDPStr("a=3GPP-Adaptation-Support:");
const char* k3gppRateAdaptationReportFreqPrefName = "3gpp_protocol_rate_adaptation_report_frequency";

Bool16 QTSS3GPPModuleUtils::s3gppEnabled = false;
Bool16 QTSS3GPPModuleUtils::s3gppRateAdaptationEnabled = false;
UInt16 QTSS3GPPModuleUtils::s3gppRateAdaptationReportFrequency = 1;

void QTSS3GPPModuleUtils::Initialize(QTSS_Initialize_Params* initParams)
{
if (NULL == initParams)
return;

sServer = initParams->inServer;
sServerPrefs = initParams->inPrefs;
sMessages = initParams->inMessages;
sErrorLog = initParams->inErrorLogStream;

}

void QTSS3GPPModuleUtils::ValidatePrefs()
{

// min and max values per 3gpp rel-6 A26234 5.3.3.5
if (s3gppRateAdaptationReportFrequency < 1 || s3gppRateAdaptationReportFrequency > 9)
QTSSModuleUtils::LogPrefErrorStr( qtssWarningVerbosity, (char*) k3gppRateAdaptationReportFreqPrefName, "has an invalid value: valid range is [1..9]");

if (s3gppRateAdaptationReportFrequency < 1)
s3gppRateAdaptationReportFrequency = 1;

if (s3gppRateAdaptationReportFrequency > 9)
s3gppRateAdaptationReportFrequency = 9;


}



void QTSS3GPPModuleUtils::ReadPrefs()
{

const Bool16 kDefaultEnable = true;
const UInt16 kDefaultReportFreq = 1;
QTSSModuleUtils::GetAttribute(sServerPrefs,"enable_3gpp_protocol", qtssAttrDataTypeBool16,
&s3gppEnabled,(void *)&kDefaultEnable, sizeof(s3gppEnabled));

QTSSModuleUtils::GetAttribute(sServerPrefs,"enable_3gpp_protocol_rate_adaptation", qtssAttrDataTypeBool16,
&s3gppRateAdaptationEnabled,(void *)&kDefaultEnable, sizeof(s3gppRateAdaptationEnabled));

QTSSModuleUtils::GetAttribute(sServerPrefs, (char *) k3gppRateAdaptationReportFreqPrefName, qtssAttrDataTypeUInt16,
&s3gppRateAdaptationReportFrequency,(void *)&kDefaultReportFreq, sizeof(s3gppRateAdaptationReportFrequency));


QTSS3GPPModuleUtils::ValidatePrefs();
}

SDPContainer* QTSS3GPPModuleUtils::Get3GPPSDPFeatureListCopy(ResizeableStringFormatter &buffer)
{
SDPContainer* resultList = NEW SDPContainer;
StrPtrLen theLinePtr;


if (s3gppEnabled)
{
if (s3gppRateAdaptationEnabled)
{
buffer.Put(s3gppBitRateAdaptationSDPStr);
buffer.Put((SInt32) s3gppRateAdaptationReportFrequency);
buffer.PutEOL();
theLinePtr.Set(buffer.GetBufPtr(),buffer.GetBytesWritten());
resultList->AddHeaderLine(&theLinePtr);
buffer.Reset();
}

}


return resultList;
}

74 changes: 74 additions & 0 deletions APICommonCode/QTSS3GPPModuleUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
/*
File: QTSS3GPPModuleUtils.h

Contains: Utility routines for 3GPP modules to use.

*/


#ifndef _QTSS_3GPP_MODULE_UTILS_H_
#define _QTSS_3GPP_MODULE_UTILS_H_

#include <stdlib.h>
#include "SafeStdLib.h"
#include "QTSS.h"
#include "StrPtrLen.h"
#include "SDPUtils.h"

class QTSS3GPPModuleUtils
{
public:


static void Initialize(QTSS_Initialize_Params* initParams);
static void ReadPrefs();


static SDPContainer* Get3GPPSDPFeatureListCopy(ResizeableStringFormatter &buffer);

private:

static void ValidatePrefs();

//
// Used in the implementation of the above functions

static QTSS_TextMessagesObject sMessages;
static QTSS_ServerObject sServer;
static QTSS_PrefsObject sServerPrefs;
static QTSS_StreamRef sErrorLog;
static StrPtrLen s3gppBitRateAdaptationSDPStr;
static Bool16 s3gppEnabled;
static Bool16 s3gppRateAdaptationEnabled;
static UInt16 s3gppRateAdaptationReportFrequency;



};


#endif //_QTSS_3GPP_MODULE_UTILS_H_
6 changes: 3 additions & 3 deletions APICommonCode/QTSSMemoryDeleter.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
*
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
Expand Down
Loading