videoplayback/videohelix/src/mpxvideodrmhelper.cpp
changeset 0 96612d01cf9f
child 6 7d91903f795f
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   This class handles the DRM functions for the playback plugin
       
    15 *
       
    16 */
       
    17 
       
    18 // Version : %version: 7 %
       
    19 
       
    20 
       
    21 #include <caf/data.h>
       
    22 #include <caf/caftypes.h>
       
    23 #include <caf/content.h>
       
    24 #include <Oma2Agent.h>
       
    25 
       
    26 #include "mpxvideodrmhelper.h"
       
    27 #include "mpxvideo_debug.h"
       
    28 
       
    29 CMpxVideoDrmHelper::CMpxVideoDrmHelper()
       
    30 {
       
    31 }
       
    32 
       
    33 CMpxVideoDrmHelper::~CMpxVideoDrmHelper()
       
    34 {
       
    35     if ( iDrmUtility )
       
    36     {
       
    37         delete iDrmUtility;
       
    38         iDrmUtility = NULL;
       
    39     }
       
    40 }
       
    41 
       
    42 
       
    43 CMpxVideoDrmHelper* CMpxVideoDrmHelper::NewL()
       
    44 {
       
    45     CMpxVideoDrmHelper* self = new( ELeave ) CMpxVideoDrmHelper();
       
    46     CleanupStack::PushL( self );
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop();
       
    49     return self;
       
    50 }
       
    51 
       
    52 void CMpxVideoDrmHelper::ConstructL()
       
    53 {
       
    54     iDrmUtility = DRM::CDrmUtility::NewL();
       
    55 }
       
    56 
       
    57 //  ------------------------------------------------------------------------------------------------
       
    58 //    CMpxVideoDrmHelper::IsProtected()
       
    59 //  ------------------------------------------------------------------------------------------------
       
    60 //
       
    61 TBool CMpxVideoDrmHelper::IsProtected( RFile& aFile )
       
    62 {
       
    63     TBool drmProtected = EFalse;
       
    64 
       
    65     if ( aFile.SubSessionHandle() )
       
    66     {
       
    67         MPX_TRAPD( err, drmProtected = iDrmUtility->IsProtectedL( aFile ) );
       
    68     }
       
    69 
       
    70     MPX_DEBUG(_L("CMpxVideoDrmHelper::IsProtected(%d)"), drmProtected);
       
    71 
       
    72     return drmProtected;
       
    73 }
       
    74 
       
    75 //  ------------------------------------------------------------------------------------------------
       
    76 //    CMpxVideoDrmHelper::GetDrmRightsStatus()
       
    77 //  ------------------------------------------------------------------------------------------------
       
    78 //
       
    79 TInt CMpxVideoDrmHelper::GetDrmRightsStatus( RFile& aFile )
       
    80 {
       
    81     MPX_ENTER_EXIT(_L("CMpxVideoDrmHelper::GetDrmRightsStatus()"));
       
    82 
       
    83     TInt drmError = KErrNone;
       
    84 
       
    85     if ( IsProtected( aFile ) )
       
    86     {
       
    87         ContentAccess::CData* data = NULL;
       
    88 
       
    89         //
       
    90         //  Check if rights exist for clip
       
    91         //
       
    92         MPX_TRAP( drmError,
       
    93                   data = ContentAccess::CData::NewL( aFile,
       
    94                                                      ContentAccess::KDefaultContentObject,
       
    95                                                      ContentAccess::EPlay ) );
       
    96 
       
    97         if ( drmError == KErrNone )
       
    98         {
       
    99             drmError = data->EvaluateIntent( ContentAccess::EPlay );
       
   100 
       
   101             delete data;
       
   102         }
       
   103     }
       
   104 
       
   105     MPX_DEBUG(_L("CMpxVideoDrmHelper::GetDrmRightsStatus() drmError = %d"), drmError);
       
   106 
       
   107     return drmError;
       
   108 }
       
   109 
       
   110 TBool CMpxVideoDrmHelper::IsTvOutAllowedL( RFile& aFile )
       
   111 {
       
   112     TBool tvOutAllowed = ETrue;
       
   113 
       
   114     if ( IsProtected( aFile ) )
       
   115     {
       
   116         ContentAccess::CContent* content = ContentAccess::CContent::NewLC( aFile );
       
   117 
       
   118         ContentAccess::CData* data = content->OpenContentL( ContentAccess::EPeek );
       
   119 
       
   120         TInt fileType;
       
   121 
       
   122         TInt error = data->GetAttribute( ContentAccess::EFileType, fileType );
       
   123 
       
   124         if ( error == KErrNone )
       
   125         {
       
   126             //
       
   127             //  TV-out is not allowed for DRM content other than OMA1 DRM
       
   128             //
       
   129             if ( fileType != ContentAccess::EOma1Dcf )
       
   130             {
       
   131                 tvOutAllowed = EFalse;
       
   132             }
       
   133         }
       
   134 
       
   135         delete data;
       
   136 
       
   137         CleanupStack::PopAndDestroy( content );
       
   138     }
       
   139 
       
   140     MPX_DEBUG(_L("CMpxVideoDrmHelper::IsTvOutAllowedL(%d)"), tvOutAllowed);
       
   141 
       
   142     return tvOutAllowed;
       
   143 }
       
   144 
       
   145 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   146 
       
   147 //  ------------------------------------------------------------------------------------------------
       
   148 //    CMpxVideoDrmHelper::IsProtected64()
       
   149 //  ------------------------------------------------------------------------------------------------
       
   150 //
       
   151 TBool CMpxVideoDrmHelper::IsProtected64( RFile64& aFile )
       
   152 {
       
   153     TBool drmProtected = EFalse;
       
   154 
       
   155     if ( aFile.SubSessionHandle() )
       
   156     {
       
   157         MPX_TRAPD( err, drmProtected = iDrmUtility->IsProtectedL( aFile ) );
       
   158     }
       
   159 
       
   160     MPX_DEBUG(_L("CMpxVideoDrmHelper::IsProtected64(%d)"), drmProtected);
       
   161 
       
   162     return drmProtected;
       
   163 }
       
   164 
       
   165 //  ------------------------------------------------------------------------------------------------
       
   166 //    CMpxVideoDrmHelper::GetDrmRightsStatus64()
       
   167 //  ------------------------------------------------------------------------------------------------
       
   168 //
       
   169 TInt CMpxVideoDrmHelper::GetDrmRightsStatus64( RFile64& aFile )
       
   170 {
       
   171     MPX_ENTER_EXIT(_L("CMpxVideoDrmHelper::GetDrmRightsStatus64()"));
       
   172 
       
   173     TInt drmError = KErrNone;
       
   174 
       
   175     if ( IsProtected64( aFile ) )
       
   176     {
       
   177         ContentAccess::CData* data = NULL;
       
   178 
       
   179         //
       
   180         //  Check if rights exist for clip
       
   181         //
       
   182         MPX_TRAP( drmError,
       
   183                   data = ContentAccess::CData::NewL( aFile,
       
   184                                                      ContentAccess::KDefaultContentObject,
       
   185                                                      ContentAccess::EPlay ) );
       
   186 
       
   187         if ( drmError == KErrNone )
       
   188         {
       
   189             drmError = data->EvaluateIntent( ContentAccess::EPlay );
       
   190 
       
   191             delete data;
       
   192         }
       
   193     }
       
   194 
       
   195     MPX_DEBUG(_L("CMpxVideoDrmHelper::GetDrmRightsStatus64() drmError = %d"), drmError);
       
   196 
       
   197     return drmError;
       
   198 }
       
   199 
       
   200 //  ------------------------------------------------------------------------------------------------
       
   201 //    CMpxVideoDrmHelper::IsTvOutAllowed64L()
       
   202 //  ------------------------------------------------------------------------------------------------
       
   203 //
       
   204 TBool CMpxVideoDrmHelper::IsTvOutAllowed64L( RFile64& aFile )
       
   205 {
       
   206     TBool tvOutAllowed = ETrue;
       
   207 
       
   208     if ( IsProtected64( aFile ) )
       
   209     {
       
   210         ContentAccess::CContent* content = ContentAccess::CContent::NewLC( aFile );
       
   211 
       
   212         ContentAccess::CData* data = content->OpenContentL( ContentAccess::EPeek );
       
   213 
       
   214         TInt fileType;
       
   215 
       
   216         TInt error = data->GetAttribute( ContentAccess::EFileType, fileType );
       
   217 
       
   218         if ( error == KErrNone )
       
   219         {
       
   220             //
       
   221             //  TV-out is not allowed for DRM content other than OMA1 DRM
       
   222             //
       
   223             if ( fileType != ContentAccess::EOma1Dcf )
       
   224             {
       
   225                 tvOutAllowed = EFalse;
       
   226             }
       
   227         }
       
   228 
       
   229         delete data;
       
   230 
       
   231         CleanupStack::PopAndDestroy( content );
       
   232     }
       
   233 
       
   234     MPX_DEBUG(_L("CMpxVideoDrmHelper::IsTvOutAllowed64L(%d)"), tvOutAllowed);
       
   235 
       
   236     return tvOutAllowed;
       
   237 }
       
   238 
       
   239 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
   240 
       
   241 //  EOF