A kind of offline player method of online encrypted slice video based on ios operating system and
Device
Technical field
The present invention relates to mobile terminal encrypted video deciphering field and multimedia technology field, more particularly, to a kind of hls
(http live streaming is a stream media network host-host protocol based on http being proposed by Apple) encrypts
The scheme that the deciphering of transmission and mobile terminal is play.
Background technology
Fast development along with development of Mobile Internet technology and the extensive popularization of smart mobile phone, mobile phone is more and more deeper
The life changing us, carry the several functions such as financing, shopping, diet, amusement, learning life.
Video also produces in a large number as important information transmitting medium in people's life, the maturation with mobile Internet.
Based on current video copyright protecting particularly educational institution's video resource protection set out, mobile terminal video-encryption demand meet the tendency and
Raw.
For mobile terminal video protection, the scheme taken at present mainly comprises following several.
1. video data key component encipherment scheme
Know-why: the data structure based on flv or mp4 file, by existing algorithm or custom algorithm, encrypted video
File header, obscures file, even if thus realizing video by illegal download, the mesh of ordinary video player None- identified
's.
Playing flow: while loading video, according to the encrypted video part of the algorithm deciphering response defining, will decipher
Data and other data for encryption, reconfigure as a complete video, realize playing
AES: in the program, conventional algorithm is xor (XOR), (full name is data encryption to des
Standard, is a kind of block algorithm of use key encryption) etc..
2. video data section protocol
Know-why: the data structure based on flv or mp4 file, is standard according to key frame or set time length, will
One video slicing stores for several videos.
Playing flow: define player, according to fixed section protocol, sequentially play video
AES: no
3.hls solution
Know-why: hls is that Apple is directed to the mobile devices such as iphone, ipod, itouch and ipad and develops
Streaming media solutions based on http agreement.This technology ultimate principle is that video file or video flowing are cut into video segment
((transport stream, mpeg2-ts, transport stream, are a kind of transmission to ts file and storage comprises audio, video and communication
The reference format of the various data of agreement)) and ((m3u is a kind of file playing multimedia list to m3u8 file to set up index file
Form, m3u8 is the m3u of unicode version, is encoded with utf-8.)).H.264 the video flowing supported is encoded to, audio frequency stream encryption
For aac.
With respect to data simple video microtomy, this technology increased burst encryption function, and that will cut into slices is every
Individual ts file carries out aes128 high strength encrypting.
Playing flow: according to m3u8 index file, load ts and deciphering file, using this deciphering file ts file decryption
Play out for normal data.
AES: aes128
The shortcoming of prior art:
- video data key component encipherment scheme needs to be decrypted according to the video file of download, is unfavorable for moving
End carries out streaming broadcasting.
- video data section protocol is not then encrypted, and cracks easily.
Although-hls encryption scheme is ripe, scheme disclosedization, as long as reading under m3u8 index and deciphering file
Carry or play.
Content of the invention
The present invention propose a kind of safer, easily broadcast offline based on the online encrypted slice video of ios operating system
Put method.
The technical scheme is that and be achieved in that:
A kind of offline player method of online encrypted slice video based on ios operating system that the present invention provides, comprising:
The integrity of verification user's registration information and accuracy, if incorrect, terminate to download flow process;If correct, carry out
Below step;
According to the user instruction comprising foradownloaded video vid and corresponding definition, inquire about local data base and whether there is institute
State the downloading task that vid does not complete, if existing, read downloading task in internal memory, and corresponding for local data base download is appointed
Business data entry deletion;If not existing, check that mobile terminal whether there is described vid any definition foradownloaded video, if depositing
Then terminating to download, if not existing, creating described vid and definition corresponding video downloading task is stored in internal memory;
Described downloading task is executed according to user instruction, corresponding with definition to vid described in external network server acquisition request
The subindex m3u8 resource comprising multiple ts resource files be stored in internal memory;
The described subindex m3u8 resource of encryption is decrypted by aes algorithm, and reads in subindex m3u8 resource
Each ts resource carry out url, and asynchronous download each ts resource conservation to the temp directory of mobile terminal;
Check whether described ts resource file downloads the ts resource completely if imperfect, re-downloading omission, if retrying
After repeatedly, ts is also imperfect, then notify user to download mistake and terminate to download flow process;If downloading complete, in the download of downloader
The subdirectory that directory creating is named with vid, is stored in all ts resource movements in temp directory to this subdirectory described vid
In;
Ask and obtain the internal memory that deciphering file resource is stored in mobile terminal to external network server;Deciphering file to encryption
Resource is decrypted acquisition decrypted result by aes algorithm, and described decrypted result is named in write download directory with vid;
The url changing each the ts resource described in described subindex m3u8 resource is download from the beginning of download directory
Local relative path, and by amended subindex m3u8 resource with vid name write download directory in;
Play instruction according to user generates signature parameter and sends with described signature parameter url to home server
Http request;
According to described http request, described url and signature parameter are verified, if correct, execute next step, if not just
True then return the null response with 403http conditional code;
Retrieval download directory whether there is the video of corresponding described vid, if existing, returning and comprising amended subindex
The content of m3u8 resource file, obtains encryption file according to described content, and is solved according to the decipherment algorithm specified obtaining
Heavy seeding is put;If not existing, terminate playing flow.
A kind of corresponding as mentioned above offline playing device of online encrypted slice video based on ios operating system, comprising:
Downloader, for verifying to user's registration information, and initializes downloading task storage by vid and definition
In internal memory, it is downloaded task and encrypted video resource, subindex m3u8 file, the deciphering of deciphering file, reduction and group
Close;
Local data base, is the sqlite data base building in mobile terminal, under not completing for persistent storage
Carry mission bit stream;
Home server, for being responsible for the resource after downloader download process is indexed, and responds from player
Http request;
Player, generates signature parameter and to the home server transmission described signature of band for the play instruction according to user
The http request of parameter url, is decrypted the offline encrypted video of broadcasting using deciphering file after receiving response.
The offline player method of online encrypted slice video based on ios operating system and device that the present invention provides, play
Locally offline encrypted video play by device needs to send the request with signature to home server, and home server only verifies signature
Just local offline video resource can be responded to player after correct.This signature generates needs user profile to enter row operation.And download
The decipherment algorithm that device is used in decrypting process also adds the computing of user profile.Therefore, user's registration information imperfect or
Incorrect be all unable to normal play offline video resource, enhance the safety of local offline video.The online broadcasting side of hls encryption
Case no doubt safety, but always need the Internet to connect, need customer flow, user cannot play in the environment of not having network and regard
Frequently.This programme follows standard hls agreement, and by all caching resources using in the protocol in local, and using local
Server returns to player by http response local resource and plays out.Therefore operate more easy.
Brief description
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing
Have technology description in required use accompanying drawing be briefly described it is clear that, drawings in the following description be only this
Some embodiments of invention, for those of ordinary skill in the art, without having to pay creative labor, also may be used
So that other accompanying drawings are obtained according to these accompanying drawings.
Fig. 1 is a kind of flow chart of the offline player method of online encrypted slice video based on ios operating system of the present invention.
Fig. 2 shows for a kind of broadcasting of the offline player method of online encrypted slice video based on ios operating system of the present invention
It is intended to.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation description is it is clear that described embodiment is only a part of embodiment of the present invention, rather than whole embodiments.It is based on
Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of not making creative work
Embodiment, broadly falls into the scope of protection of the invention.
Refer to Fig. 1 it is preferred that a kind of offline player method of online encrypted slice video based on ios operating system, wrap
Include:
The integrity of verification user's registration information and accuracy, if incorrect, terminate to download flow process;If correct, carry out
Below step;
According to the user instruction comprising foradownloaded video vid and corresponding definition, inquire about local data base and whether there is institute
State the downloading task that vid does not complete, if existing, read downloading task in internal memory, and corresponding for local data base download is appointed
Business data entry deletion;If not existing, check that mobile terminal whether there is described vid any definition foradownloaded video, if depositing
Then terminating to download, if not existing, creating described vid and definition corresponding video downloading task is stored in internal memory;
Described downloading task is executed according to user instruction, corresponding with definition to vid described in external network server acquisition request
The subindex m3u8 resource comprising multiple ts resource files be stored in internal memory;
The described subindex m3u8 resource of encryption is decrypted by aes algorithm, and reads in subindex m3u8 resource
Each ts resource carry out url, and asynchronous download each ts resource conservation to the temp directory of mobile terminal;
Check whether described ts resource file downloads the ts resource completely if imperfect, re-downloading omission, if retrying
After repeatedly, ts is also imperfect, then notify user to download mistake and terminate to download flow process;If downloading complete, in the download of downloader
The subdirectory that directory creating is named with vid, is stored in all ts resource movements in temp directory to this subdirectory described vid
In;
Ask and obtain the internal memory that deciphering file resource is stored in mobile terminal to external network server;Deciphering file to encryption
Resource is decrypted acquisition decrypted result by aes algorithm, and described decrypted result is named in write download directory with vid;
The url changing each the ts resource described in described subindex m3u8 resource is download from the beginning of download directory
Local relative path, and by amended subindex m3u8 resource with vid name write download directory in;
Play instruction according to user generates signature parameter and sends the url's with described signature parameter to home server
Http request;
According to described http request, described url and signature parameter are verified, if correct, execute next step, if not just
True then return the null response with 403http conditional code;
Retrieval download directory whether there is the video of corresponding described vid, if existing, returning and comprising amended subindex
The content of m3u8 resource file, obtains encryption file according to described content, and is solved according to the decipherment algorithm specified obtaining
Heavy seeding is put;If not existing, terminate playing flow.
Preferably, if download complete in execution step, create with the subdirectory of vid name in the download directory of downloader,
Described vid be stored in all ts resource movements in temp directory to this subdirectory when, if user exits in downloading process
Mobile terminal application program, then when exiting, downloading task is stored in local data base.
Preferably, when execution generates signature parameter step according to the play instruction of user, its specific method is ought
Front time, vid and user's registration information are spliced into character string, then carry out md5 computing generation signature parameter.
Preferably, described in the execution described subindex m3u8 resource of modification, the url of each ts resource is download
The local relative path starting from download directory, and amended subindex m3u8 resource is named write download directory with vid
When middle;Also include step change #ext-x-key field uri attribute be locally deciphering file from download directory start relative
Path.
Preferably, whether there is the video of corresponding described vid in execution retrieval download directory, if existing, returning and comprising to repair
The content of the subindex m3u8 resource file after changing, obtains encryption file according to described content, and according to the solution specified obtaining
When close algorithm is decrypted the step of broadcasting, its specific method is that the uri attribute acquisition read in #ext-x-key field adds
Ciphertext part, and the initialization vector that the decryption method specified according to the method attribute of #ext-x-key field and iv attribute are specified
It is decrypted broadcasting.
Preferably, the present invention also provides corresponding with said method a kind of cut based on the online encryption of ios operating system
The offline playing device of piece video, comprising:
Downloader, for verifying to user's registration information, and initializes downloading task storage by vid and definition
In internal memory, it is downloaded task and encrypted video resource, subindex m3u8 file, the deciphering of deciphering file, reduction and group
Close;
Local data base, is the sqlite data base building in mobile terminal, under not completing for persistent storage
Carry mission bit stream;
Home server, for being responsible for the resource after downloader download process is indexed, and responds from player
Http request;
Player, generates signature parameter and to the home server transmission described signature of band for the play instruction according to user
The http request of parameter url, is decrypted the offline encrypted video of broadcasting using deciphering file after receiving response.
Preferably, described downloader, local data base, home server and player all encapsulate with sdk in.Whole from
Line caching, deciphering, the process play and device (downloader, local data base, home server, player) are all encapsulated in sdk
In, user only needs to using vid (video identity, video unique identifier are formulated by server) and user in service
Log-on message (userid, writetoken, readtoken, secretkey) and the sdk interface of device interact, you can complete
The offline cache of online encrypted video and broadcasting.User can obtain related log-on message and vid from server background.User
Need not understand or intervene complex process therein it is only necessary to call sdk interface it is possible to complete whole process.User is using more
For convenience, safety.Therefore user only need to call sdk interface, configuration user's registration information and download directory when using.The present invention carries
For the offline player method of online encrypted slice video based on ios operating system in, the money directly asking and obtain from outer net
Source (m3u8 file, deciphering file) be all to encrypt resource, and ciphering process completes in destination server, whole decrypting process and using
Device (downloader, player) all complete in mobile terminal.Even if by instrument sniff and intercept and capture mobile terminal to outer net request,
Reply data stream, nor use, because this is the resource of encryption, the resource through the decrypting process of agreement is not all one
Common binary file, has ensured the safety of encrypted video from source.
Locally offline encrypted video is that home server rings by sending http request to home server to player plays
Should the mode of local offline video resource realize.Therefore, all requests that player sends, are all to send to home server
Request, rather than offline video resource is directly accessed by path.And home server herein only responds and comes from movement
The request that end the machine sends.Therefore, even if passing through instrument sniff and getting the request data stream of player, nor in outside
(equipment beyond this mobile terminal) acquisition request is to resource.Disguise and the safety of offline encrypted video position are ensured.
Locally offline encrypted video needs to send the request with signature to home server player plays, and book server is only
Just local offline video resource can be responded to player after having checking signature correct.This signature generates needs user profile to be transported
Calculate.And the decipherment algorithm used in decrypting process of downloader also adds the computing of user profile.Therefore, user's registration information
Imperfect or incorrect be all unable to normal play offline video resource.Enhance the safety of local offline video.
The foregoing is only presently preferred embodiments of the present invention, not in order to limit the present invention, all essences in the present invention
Within god and principle, any modification, equivalent substitution and improvement made etc., should be included within the scope of the present invention.