42 #include <nsComponentManagerUtils.h>
81 NS_ENSURE_ARG_POINTER(aFile);
90 mFileInputStream = do_CreateInstance
91 (
"@mozilla.org/network/file-input-stream;1", &rv);
92 NS_ENSURE_SUCCESS(rv, rv);
93 rv = mFileInputStream->Init(mFile,
PR_RDONLY, 0, 0);
94 NS_ENSURE_SUCCESS(rv, rv);
97 mSeekableStream = do_QueryInterface(mFileInputStream, &rv);
98 NS_ENSURE_SUCCESS(rv, rv);
99 mInputStream = do_QueryInterface(mFileInputStream, &rv);
100 NS_ENSURE_SUCCESS(rv, rv);
115 mInputStream->Close();
116 mInputStream = nsnull;
138 rv = mFile->GetFileSize(&fileSize);
139 NS_ENSURE_SUCCESS(rv, rv);
140 endOffset = fileSize;
146 rv =
AtomPathGet(
"/moov/udta/meta", &atom, &offset, &endOffset);
147 NS_ENSURE_SUCCESS(rv, rv);
152 rv =
AtomPathGet(
"/ilst/apID/data", &atom, &offset, &endOffset);
153 NS_ENSURE_SUCCESS(rv, rv);
157 PRUint32 accountNameSize = (PRUint32)(endOffset - offset);
160 char* accountNameBuffer = (
char*) NS_Alloc(accountNameSize + 1);
161 NS_ENSURE_TRUE(accountNameBuffer, NS_ERROR_OUT_OF_MEMORY);
166 rv = mSeekableStream->Seek(nsISeekableStream::NS_SEEK_SET, offset);
167 NS_ENSURE_SUCCESS(rv, rv);
168 rv = mInputStream->Read(accountNameBuffer, accountNameSize, &bytesRead);
169 NS_ENSURE_SUCCESS(rv, rv);
170 NS_ENSURE_TRUE(bytesRead >= accountNameSize, NS_ERROR_FAILURE);
171 accountNameBuffer[accountNameSize] =
'\0';
174 aAccountName.Assign(NS_ConvertUTF8toUTF16(accountNameBuffer));
198 rv = mFile->GetFileSize(&fileSize);
199 NS_ENSURE_SUCCESS(rv, rv);
200 endOffset = fileSize;
210 NS_ENSURE_SUCCESS(rv, rv);
215 rv =
AtomPathGet(
"/drms", &atom, &offset, &endOffset);
216 NS_ENSURE_SUCCESS(rv, rv);
220 rv =
AtomPathGet(
"/sinf/schi/name", &atom, &offset, &endOffset);
221 NS_ENSURE_SUCCESS(rv, rv);
225 PRUint32 userNameSize = (PRUint32)(endOffset - offset);
228 char* userNameBuffer = (
char*) NS_Alloc(userNameSize + 1);
229 NS_ENSURE_TRUE(userNameBuffer, NS_ERROR_OUT_OF_MEMORY);
234 rv = mSeekableStream->Seek(nsISeekableStream::NS_SEEK_SET, offset);
235 NS_ENSURE_SUCCESS(rv, rv);
236 rv = mInputStream->Read(userNameBuffer, userNameSize, &bytesRead);
237 NS_ENSURE_SUCCESS(rv, rv);
238 NS_ENSURE_TRUE(bytesRead >= userNameSize, NS_ERROR_FAILURE);
239 userNameBuffer[userNameSize] =
'\0';
242 aUserName.Assign(NS_ConvertUTF8toUTF16(userNameBuffer));
260 NS_ENSURE_ARG_POINTER(aUserID);
270 rv = mFile->GetFileSize(&fileSize);
271 NS_ENSURE_SUCCESS(rv, rv);
272 endOffset = fileSize;
282 NS_ENSURE_SUCCESS(rv, rv);
287 rv =
AtomPathGet(
"/drms", &atom, &offset, &endOffset);
288 NS_ENSURE_SUCCESS(rv, rv);
292 rv =
AtomPathGet(
"/sinf/schi/user", &atom, &offset, &endOffset);
293 NS_ENSURE_SUCCESS(rv, rv);
296 PRUint32 userIDAtom[3];
299 rv = mSeekableStream->Seek(nsISeekableStream::NS_SEEK_SET, offset);
300 NS_ENSURE_SUCCESS(rv, rv);
301 rv = mInputStream->Read((
char *) userIDAtom,
sizeof(userIDAtom), &bytesRead);
302 NS_ENSURE_SUCCESS(rv, rv);
303 NS_ENSURE_TRUE(bytesRead >=
sizeof(userIDAtom), NS_ERROR_FAILURE);
304 userID = PR_ntohl(userIDAtom[2]);
330 rv = mFile->GetFileSize(&fileSize);
331 NS_ENSURE_SUCCESS(rv, rv);
333 endOffset = fileSize;
336 rv =
AtomPathGet(
"/sean", &atom, &offset, &endOffset);
337 NS_ENSURE_SUCCESS(rv, rv);
338 offset += mAtomHdrSize;
343 PRUint64 userIDEndOffset = endOffset;
344 rv =
AtomPathGet(
"/user", &atom, &offset, &userIDEndOffset);
349 PRUint32 userIDAtom[3];
352 rv = mSeekableStream->Seek(nsISeekableStream::NS_SEEK_SET, offset);
353 NS_ENSURE_SUCCESS(rv, rv);
354 rv = mInputStream->Read((
char *) userIDAtom,
357 NS_ENSURE_SUCCESS(rv, rv);
358 NS_ENSURE_TRUE(bytesRead >=
sizeof(userIDAtom), NS_ERROR_FAILURE);
359 userID = PR_ntohl(userIDAtom[2]);
362 aUserIDList.AppendElement(userID);
389 PRUint64* aStartOffset,
390 PRUint64* aEndOffset)
393 NS_ASSERTION(aAtomPath,
"aAtomPath is null");
394 NS_ASSERTION(aAtom,
"aAtom is null");
395 NS_ASSERTION(aStartOffset,
"aStartOffset is null");
396 NS_ASSERTION(aEndOffset,
"aEndOffset is null");
403 PRUint64
offset = *aStartOffset;
404 PRUint64 endOffset = *aEndOffset;
407 int numAtoms = strlen(aAtomPath) / 5;
408 const char* pAtomType = aAtomPath;
409 for (
int i = 0;
i < numAtoms;
i++) {
415 offset += mAtomHdrSize;
418 PRUint32 atomType = (pAtomType[0] << 24) |
419 (pAtomType[1] << 16) |
420 (pAtomType[2] << 8) |
425 rv = AtomGet(atomType, &atom, &offset, &endOffset);
431 memcpy(aAtom, atom,
sizeof(atom));
433 *aEndOffset = endOffset;
454 QTAtomReader::AtomGet(PRUint32 aAtomType,
456 PRUint64* aStartOffset,
457 PRUint64* aEndOffset)
460 NS_ASSERTION(aAtom,
"aAtom is null");
461 NS_ASSERTION(aStartOffset,
"aStartOffset is null");
462 NS_ASSERTION(aEndOffset,
"aEndOffset is null");
469 PRUint64
offset = *aStartOffset;
470 PRUint64 endOffset = *aEndOffset;
473 PRBool found = PR_FALSE;
474 while (offset < endOffset) {
476 rv = mSeekableStream->Seek(nsISeekableStream::NS_SEEK_SET, offset);
477 NS_ENSURE_SUCCESS(rv, rv);
481 rv = mInputStream->Read((
char *) atom,
sizeof(atom), &bytesRead);
482 NS_ENSURE_SUCCESS(rv, rv);
483 NS_ENSURE_TRUE(bytesRead >=
sizeof(atom), NS_ERROR_FAILURE);
486 atom[0] = PR_ntohl(atom[0]);
487 atom[1] = PR_ntohl(atom[1]);
490 PRUint32 curAtomSize = atom[0];
491 PRUint32 curAtomType = atom[1];
494 NS_ENSURE_TRUE(curAtomSize >= mAtomHdrSize, NS_ERROR_FAILURE);
497 if (curAtomType == aAtomType) {
501 offset += curAtomSize;
507 return NS_ERROR_FAILURE;
510 memcpy(aAtom, atom,
sizeof(atom));
512 *aEndOffset = offset + atom[0];
nsresult GetFairPlayAccountName(nsAString &aAccountName)
nsresult GetFairPlayUserName(nsAString &aUserName)
nsresult Open(nsIFile *aFile)
QuickTime Atom Reader Definitions.
nsresult GetIEKInfoUserIDs(nsTArray< PRUint32 > &aUserIDList)
nsresult AtomPathGet(const char *aAtomPath, void *aAtom, PRUint64 *aStartOffset, PRUint64 *aEndOffset)
_getSelectedPageStyle s i
nsresult GetFairPlayUserID(PRUint32 *aUserID)