OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions | |
6 * are met: | |
7 * 1. Redistributions of source code must retain the above copyright | |
8 * notice, this list of conditions and the following disclaimer. | |
9 * 2. Redistributions in binary form must reproduce the above copyright | |
10 * notice, this list of conditions and the following disclaimer in the | |
11 * documentation and/or other materials provided with the distribution. | |
12 * | |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | |
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | |
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | |
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
23 * THE POSSIBILITY OF SUCH DAMAGE. | |
24 */ | |
25 | |
26 #ifndef CDM_h | |
27 #define CDM_h | |
28 | |
29 #if ENABLE(ENCRYPTED_MEDIA_V2) | |
30 | |
31 #include "wtf/Forward.h" | |
32 #include "wtf/PassRefPtr.h" | |
33 #include "wtf/Uint8Array.h" | |
34 #include "wtf/text/WTFString.h" | |
35 | |
36 namespace WebCore { | |
37 | |
38 class CDM; | |
39 class CDMPrivateInterface; | |
40 class CDMSession; | |
41 class MediaPlayer; | |
42 | |
43 typedef PassOwnPtr<CDMPrivateInterface> (*CreateCDM)(CDM*); | |
44 typedef bool (*CDMSupportsKeySystem)(const String&); | |
45 | |
46 class CDMClient { | |
47 public: | |
48 virtual ~CDMClient() { } | |
49 | |
50 virtual MediaPlayer* cdmMediaPlayer(const CDM*) const = 0; | |
51 }; | |
52 | |
53 class CDMSession { | |
54 public: | |
55 CDMSession() { } | |
56 virtual ~CDMSession() { } | |
57 | |
58 virtual const String& sessionId() const = 0; | |
59 virtual PassRefPtr<Uint8Array> generateKeyRequest(const String& mimeType, Ui
nt8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned
long& systemCode) = 0; | |
60 virtual void releaseKeys() = 0; | |
61 virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned s
hort& errorCode, unsigned long& systemCode) = 0; | |
62 }; | |
63 | |
64 class CDM { | |
65 public: | |
66 | |
67 enum CDMErrorCode { UnknownError = 1, ClientError, ServiceError, OutputError
, HardwareChangeError, DomainError }; | |
68 static bool supportsKeySystem(const String&); | |
69 static PassOwnPtr<CDM> create(const String& keySystem); | |
70 static void registerCDMFactory(CreateCDM, CDMSupportsKeySystem); | |
71 ~CDM(); | |
72 | |
73 bool supportsMIMEType(const String&) const; | |
74 PassOwnPtr<CDMSession> createSession(); | |
75 | |
76 const String& keySystem() const { return m_keySystem; } | |
77 | |
78 CDMClient* client() const { return m_client; } | |
79 void setClient(CDMClient* client) { m_client = client; } | |
80 | |
81 MediaPlayer* mediaPlayer() const; | |
82 | |
83 private: | |
84 CDM(const String& keySystem); | |
85 | |
86 String m_keySystem; | |
87 OwnPtr<CDMPrivateInterface> m_private; | |
88 CDMClient* m_client; | |
89 }; | |
90 | |
91 } | |
92 | |
93 #endif // ENABLE(ENCRYPTED_MEDIA_V2) | |
94 | |
95 #endif // CDM_h | |
OLD | NEW |