CN104269185B - Method and system for realizing sound mixing play in Java virtual machine - Google Patents
Method and system for realizing sound mixing play in Java virtual machine Download PDFInfo
- Publication number
- CN104269185B CN104269185B CN201410454859.XA CN201410454859A CN104269185B CN 104269185 B CN104269185 B CN 104269185B CN 201410454859 A CN201410454859 A CN 201410454859A CN 104269185 B CN104269185 B CN 104269185B
- Authority
- CN
- China
- Prior art keywords
- audio
- media
- audio frequency
- interfaces
- player
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Landscapes
- Reverberation, Karaoke And Other Acoustics (AREA)
- Signal Processing For Digital Recording And Reproducing (AREA)
Abstract
The invention discloses a method and a system for realizing sound mixing play in a Java virtual machine, relating to the field of Java application. The method comprises the following steps: obtaining a KNI expansion interface related to audio by using an expansion part JSR135 (Java Specification Requests) of the Java virtual machine; realizing an audio play interface of hardware equipment according to the KNI expansion interface related to audio, wherein the KNI expansion interface is provided by the JSR135 part; supporting creation of two players and simultaneous play by the hardware equipment, realizing an audio playing interface by expanding of a software development kit based on the hardware equipment, initializing the hardware equipment, creating a main player and a slave player, realizing sound mixing play control of the main player and the slave player; and compiling the expansion part JSR135 into the Java virtual machine, and generating a Java virtual machine client supporting audio play and sound mixing play. The Java virtual machine disclosed by the invention realizes sound mixing play by virtue of the main player and the slave player, and is capable of ensuring the stability of the sound mixing play.
Description
Technical field
The present invention relates to Java applications, are specifically related to a kind of method that audio mixing broadcasting is realized in Java Virtual Machine
And system.
Background technology
IPTV (Internet Protocol Television, Internet Protocol Television/IPTV) is a kind of using wide
Cable net, integrate the multiple technologies such as the Internet, multimedia, communication, providing to domestic consumer includes DTV
In the brand-new technology of interior various interactive services.IPTV service is roughly divided into basic service and the big class of value-added service two, IPTV
Basic service refer to video content services based on audio-visual content, including live, program request, carousel, time shift etc.;And IPTV
Value-added service includes game, instant messaging, E-Payment and Karaoke etc., wherein, game is divided into web game and Java trips
Two kinds of play, is the important component part of IPTV value-added services.
Java ME were referred to as J2ME in the past, were for Set Top Box, mobile phone and PDA (PersonalDigital
Assistant, personal digital assistant) etc the Java language platform that provides of embedded consumer-elcetronics devices, including virtual machine and
The Java API (Application Programming Interface, application programming interface) of series of standards.It and
Java SE, Java EE constitute together three big versions of Java technology, and again by JCP (Java Community
Process, description is proposed specification and the technology being added in Java systems) work out.
In embedded device environment, the treatment mechanism unrelated with a hardware such as Java Virtual Machine is often installed on equipment,
To allow to download and the operation on equipment.Equipment allows a Java Virtual Machine to use the language unrelated with hardware, example
Such as Java language.Java language is the cross-platform OO high-level programming language that Sun Microsystems are released, currently respectively
Individual field is increasingly widely applied, and has become one of most important programming language.Java Virtual Machine is one
Abstract computer, its main task is to load Java class files and perform bytecode therein, Java class files
It is the binary file on the hardware platform and operating system for operate in any support Java Virtual Machine, is responsible for operation Java journeys
Sequence.
The existing Java game services based on IPTV system are that Java game (i.e. J2ME programs) is transplanted to into IPTV systems
Run on system.Therefore, Java is directly or indirectly used mostly installed in set top box side, operation Java game Java Virtual Machine
Virtual machine.Java game based on IPTV is mainly remotely controlled the process such as instruction process, image show, audio frequency is played, wherein
Audio frequency plays part and realizes having differences as respective Set Top Box manufacturer chip selects different.Java Virtual Machine client will
Realize that audio playing function, will also be with reference to the hardware audio of chip manufacturer except to extend related audio interface based on J2ME specifications
Player method is completing.
Current Java Virtual Machine playback interface and the Broadcast Control processing mode of logical AND hardware device cannot be connected, and Java is empty
The audio frequency of plan machine is played and typically realizes that audio frequency is played by single player, does not support that audio mixing is played.
The content of the invention
The invention aims to overcome the shortcomings of above-mentioned background technology, there is provided one kind is realized mixed in Java Virtual Machine
The method and system that sound is played, Java Virtual Machine realizes that audio mixing is played by principal and subordinate's player, can effectively guarantee that audio mixing is played steady
It is qualitative.
The present invention provides a kind of method that audio mixing broadcasting is realized in Java Virtual Machine, comprises the following steps:
S1, obtain the KNI expansion interface related to audio frequency using the widening parts JSR135 of Java Virtual Machine;
S2, the audio frequency correlation KNI expansion interfaces provided according to JSR135 parts, realize that the audio frequency of hardware device is played and connect
Mouthful, the audio frequency play interface includes that audio frequency creates media_create interfaces, audio frequency and closes media_close interfaces, audio frequency
Release media_release_device interfaces, setting voice data media_do_buffering interfaces, startup audio frequency are played
Media_start interfaces, stopping are played media_stop interfaces, audio frequency and destroy media_destroy interfaces;Hardware device is supported
Create two players and play simultaneously, the audio frequency is realized by the SDK SDK extensions based on hardware device
Playback interface, initiating hardware equipment creates main player, from player, and the audio mixing for realizing master and slave player plays control;
S3, JSR135 parts are incorporated in Java Virtual Machine, generate and support that the Java that audio frequency is played and audio mixing is played is virtual
Machine client.
On the basis of above-mentioned technical proposal, the flow process of audio frequency play interface of hardware device is realized described in step S2 such as
Under:
S201, create and realize for play audio frequency audio frequency create media_create interfaces, the media_
Create interfaces are used for initiating hardware equipment, create main player and from player, and with reference to the life of media_create parameters
Fail to be sold at auction into audio frequency and show, it is incoming during other broadcast control methods to call by media_create parameter settings to pointer return value
Use;The global state mark of master and slave player is set:Broadcast state, time-out broadcast state and broadcasting halted state;
S202, the media_do_buffering interfaces for arranging voice data are created and realized, wait to broadcast by incoming
Put audio stream to be stored in the audio file of internal memory, and taking-up calls media_create to connect from Java Virtual Machine incoming pointer
The audio file name created during mouth, as the sign of the audio stream;
S203, create and realize for start audio frequency broadcasting media_start interfaces, it is incoming according to Java Virtual Machine
The audio stream sign of the audio frequency to be played stored in pointer, creates separate threads, and circulation is read media_do_buffering and connect
The audio stream data that oral instructions enter, and be stored in internal memory in the corresponding audio stream of audio stream sign, the audio stream for reading is handed over
Led by correspondence or carry out audio frequency broadcasting from player, the audio mixing for realizing master and slave player plays control;
S204, the media_destroy interfaces for creating and realizing audio frequency destruction, by calling based on the SDK of hardware device
The audio frequency destroying method of offer, release and destruction of the realization to the player used resource of establishment, and will create and be stored in before
The audio file of internal memory is removed;
S205, other audio frequency play interfaces are created and realize, the corresponding SDK Broadcast Controls interface or side by combined with hardware equipment
Method is realized:It is when broadcasting time-out media_pause interfaces are created, corresponding player global state traffic sign placement is temporary to play
Stop state;It is stopping shape by corresponding player global state traffic sign placement when stopping broadcasting media_stop interfaces are created
State;Realize the media_set_volume interfaces for arranging volume:By calling the volume of hardware device, function is set
Or method, and the incoming volume parameter of the interface is configured as volume value.
On the basis of above-mentioned technical proposal, media_create parameters described in step S201 include playerId,
MimeType, mimeLength, wherein, playerId presentation mediums play sign, each audio frequency unique sign in gaming;
MimeType represents audio types;MimeLength represents the length of mimeType;Audio stream sign is indicated by media play
PlayerId and audio types mimeType are described sign.
On the basis of above-mentioned technical proposal, the incoming pointer of Java Virtual Machine described in step S202 includes playing sign
ID, audio stream total length, audio types, audio stream filename, the channel number of wave formatted audio files, bit rate and sampling
Rate, wherein, play sign ID and represent that audio stream total length represents that audio types are represented with shaping with shaping, is used for long shaping
The type of sign current audio stream;Audio stream filename represents with character type, be stored in internal memory or equipment read-write region
It is interior;Channel number, bit rate, the sample rate of wave formatted audio files is represented with shaping.
On the basis of above-mentioned technical proposal, in step S203 the audio stream of reading is transferred to corresponding main or enter from player
When row audio frequency is played, the global state mark of the real-time judge player, if main player or temporary in playing from player
Stop state, then the player is set and suspends broadcasting correspondence audio stream;If main player stops shape from player in broadcasting
State, then arrange the broadcasting that the player stops immediately correspondence audio stream;Master and slave player is when audio frequency is commenced play out, and it is right to arrange
The global state for answering player is masked as broadcast state;At the end of playing audio frequency, then the global state mark of correspondence player is set
Will is broadcasting halted state, i.e. idle condition.
On the basis of above-mentioned technical proposal, correspondence described in step S203 is led or is by master and slave broadcasting from player
Judging, if first audio frequency transfers to main player to play out, main player is in seizure condition to device state, second
Audio frequency is just transferred to from player to play out;If principal and subordinate's player is simultaneously playing, show principal and subordinate's player all in accounting for
With state, the audio frequency to be played such as the 3rd just waits one of them to transfer to player idle in principal and subordinate's player again after playing
Continue to play.
The present invention also provides a kind of system that audio mixing broadcasting is realized in Java Virtual Machine for realizing said method, bag
Include the related KNI expansion interface acquiring units of audio frequency, audio frequency play interface and realize that unit, Java Virtual Machine client generate list
Unit, wherein:
The related KNI expansion interface acquiring units of the audio frequency are used for:Using the widening parts JSR135 of Java Virtual Machine
Obtain the KNI expansion interface related to audio frequency;
The audio frequency play interface realizes that unit is used for:According to the audio frequency correlation KNI expansion interfaces that JSR135 parts are provided,
The audio frequency play interface of hardware device is realized, the audio frequency play interface includes that audio frequency creates media_create interfaces, audio frequency
Close media_close interfaces, audio frequency release media_release_device interfaces, voice data media_do_ is set
Buffering interfaces, startup audio frequency play media_start interfaces, stop playing media_stop interfaces, audio frequency destruction
Media_destroy interfaces;Hardware device is supported to create two players and played simultaneously, by the software based on hardware device
The audio frequency play interface is realized in development kit SDK extensions, initiating hardware equipment, creates main player, from player, real
The audio mixing of existing master and slave player plays control;
The Java Virtual Machine client signal generating unit is used for:JSR135 parts are incorporated in Java Virtual Machine, are generated and is propped up
Hold the Java Virtual Machine client that audio frequency is played and audio mixing is played.
On the basis of above-mentioned technical proposal, the audio frequency play interface realizes that unit includes media_create interface realities
Existing subelement, media_do_buffering interfaces realize that subelement, media_start interfaces realize subelement, other audio frequency
Playback interface realizes subelement, wherein:
The media_create interfaces realize that subelement is used for:Create and realize that the audio frequency for playing audio frequency is created
Media_create interfaces, the media_create interfaces are used for initiating hardware equipment, create main player and from broadcasting
Device, and audio stream sign is generated with reference to media_create parameters, by media_create parameter settings to pointer return value,
To call incoming during other broadcast control methods use;The global state mark of master and slave player is set:Broadcast state, time-out are broadcast
Put state and play halted state;
The media_do_buffering interfaces realize that subelement is used for:Create and realize for arranging voice data
Media_do_buffering interfaces, incoming audio stream to be played is stored in internal memory, and from the incoming finger of Java Virtual Machine
Take out in pin and call the audio file name created during media_create interfaces, as the sign of the audio stream;
The media_start interfaces realize that subelement is used for:Create and realize the media_ for starting audio frequency broadcasting
Start interfaces, according to the audio stream sign of the audio frequency to be played stored in the incoming pointer of Java Virtual Machine, create independent lines
The incoming audio stream data of media_do_buffering interfaces is read in journey, circulation, and is stored in the audio stream sign in internal memory
In corresponding audio stream, transfer to correspondence main the audio stream of reading or carry out audio frequency broadcasting from player, realize master and slave player
Audio mixing play control;
Described other audio frequency play interfaces realize that subelement is used for:Other audio frequency play interfaces are created and realize, by knot
The corresponding SDK Broadcast Controls interface or method for closing hardware device is realized:When broadcasting time-out media_pause interfaces are created, will correspondence
Player global state traffic sign placement for play halted state;When stopping broadcasting media_stop interfaces are created, will correspondence
Player global state traffic sign placement be halted state;Realize that the media_set_volume for arranging volume connects
Mouthful:By calling the volume of hardware device, function or method are set, and using the incoming volume parameter of the interface as volume value
It is configured.
On the basis of above-mentioned technical proposal, the media_create parameters include playerId, mimeType,
MimeLength, wherein, playerId presentation mediums play sign, each audio frequency unique sign in gaming;mimeType
Represent audio types;MimeLength represents the length of mimeType;Audio stream sign indicates playerId by media play
Sign is described with audio types mimeType.
On the basis of above-mentioned technical proposal, the incoming pointer of the Java Virtual Machine includes playing sign ID, audio stream
Total length, audio types, audio stream filename, the channel number of wave formatted audio files, bit rate and sample rate, wherein, broadcast
Put sign ID and represent that audio stream total length represents that audio types are represented with shaping with shaping with long shaping, for indicating current sound
The type of frequency stream;Audio stream filename represents with character type, be stored in internal memory or the read-write region of equipment in;Wave forms
Channel number, bit rate, the sample rate of audio file is represented with shaping.
Compared with prior art, advantages of the present invention is as follows:
Java Virtual Machine in the present invention realizes that audio mixing is played by principal and subordinate's player, can effectively guarantee stablizing for audio mixing broadcasting
Property.
Description of the drawings
Fig. 1 is the flow chart for realizing the method that audio mixing is played in the embodiment of the present invention in Java Virtual Machine.
Fig. 2 is the flow chart of the audio frequency play interface that hardware device is realized in the embodiment of the present invention.
Specific embodiment
Below in conjunction with the accompanying drawings and specific embodiment the present invention is described in further detail.
Shown in Figure 1, the embodiment of the present invention provides a kind of method that audio mixing broadcasting is realized in Java Virtual Machine, including
Following steps:
S1, obtain the KNI expansion interface related to audio frequency using the widening parts JSR135 of Java Virtual Machine.Java is virtual
KNI expansion interfaces in machine include frequency/audio-frequency broadcasting control interface, video Broadcast Control interface and volume interface etc., and the KNI related to audio frequency expands
Exhibition interface includes frequency/audio-frequency broadcasting control interface and volume interface.
Because Java Virtual Machine is the integrated system of the multisystem of an integrated multi-environment, only it is with linux operations here
Qt (a kind of cross-platform C++ graphical user interface applications program development framework) environment under system is illustrated for example.It is wherein many
Environment includes Qte (Qte is Qt/embedded, and it is a version of Qt), fb (i.e. DirectFB, the offer of a lightweight
Hardware graphics acceleration, input equipment process and abstract shape library), (Windows Embedded Compact are (i.e. for wince
Windows CE) it is that Microsoft is embedded, mobile computing platform basis, it is one open, upgradeable 32 embedding
Enter formula operating system), win32 (32 environment of Microsoft Windows operating systems) etc., and multisystem includes
Windows, linux etc., the Java Virtual Machine source code that Sun Microsystems are provided supports that compiling generates correspondence in these environment and system
Java Virtual Machine client.
S2, the audio frequency correlation KNI expansion interfaces provided according to JSR135 parts, realize that the audio frequency of hardware device is played and connect
Mouthful.
Using the KNI expansion interfaces of JSR135, (i.e. local interface, is the Java Virtual Machine of Sun Microsystems to the embodiment of the present invention
The local method call mechanism for being used) audio frequency play interface of hardware device is realized, its KNI expansion interface is former from JSR135
KNI Direct Player.c and KNI Direct two class files of Volume.c in raw code, audio frequency play interface is main
Including:Media_create (audio frequency establishment), media_close (audio frequency closing), media_release_device (release by audio frequency
Put), media_do_buffering (setting voice data), media_start (start audio frequency play), media_stop (stop
Only play), media_destroy (audio frequency destruction) etc..Hardware device is supported to create two players and played simultaneously, by base
Realize that above-mentioned audio frequency is broadcast in SDK (Software Development Kit, the SDK) extensions of hardware device
Put interface, initiating hardware equipment creates main player, from player, and the audio mixing for realizing master and slave player plays control.
It is shown in Figure 2, realize that the flow process of the audio frequency play interface of hardware device is as follows in step S2:
S201, create and realize media_create (audio frequency establishment) interface for playing audio frequency, media_create
Interface is used for initiating hardware equipment, creates main player and from player, and generates audio frequency with reference to media_create parameters
Fail to be sold at auction and show, by media_create parameter settings to pointer return value, to call incoming during other broadcast control methods use.
Media_create parameters include playerId, mimeType, mimeLength, wherein, playerId presentation mediums play mark
Show, each audio frequency unique sign in gaming;MimeType represents audio types;MimeLength represents the length of mimeType
Degree.Audio stream sign indicates playerId by media play and audio types are described sign, such as (1001.wav).Sound
Frequency type is including wav, midi, mp3, amr, MPEG4, TONE etc..
The global state mark of master and slave player is set:Broadcast state, time-out broadcast state and broadcasting halted state are (empty
It is not busy).
S202, create and realize that the media_do_buffering (setting voice data) for arranging voice data connects
Mouthful, incoming audio stream to be played is stored in the audio file of internal memory, and tune is taken out from the incoming pointer of Java Virtual Machine
The audio file name created during with media_create (audio frequency establishment) interface, as the sign of the audio stream.
The incoming pointer of Java Virtual Machine includes playing sign ID, audio stream total length, audio types, audio frequency stream file
Name, the channel number of wave formatted audio files, bit rate and sample rate, wherein, play sign ID and represented with long shaping, audio stream
Total length represents that audio types are represented with shaping with shaping, for indicating the type of current audio stream;Audio stream filename word
Symbol type represents, be stored in internal memory or the read-write region of equipment in;The channel number of wave formatted audio files, bit rate, adopt
Sample rate is represented with shaping.
S203, media_start (the start audio frequency play) interface for starting audio frequency broadcasting is created and realizes, according to
The audio stream sign of the audio frequency to be played stored in the incoming pointer of Java Virtual Machine, creates separate threads, and circulation is read
Media_do_buffering (setting voice data) the incoming audio stream data of interface, and be stored in the audio frequency in internal memory and fail to be sold at auction
In showing corresponding audio stream, transfer to correspondence main the audio stream of reading or carry out audio frequency broadcasting from player, realize master and slave broadcasting
The audio mixing of device plays control.
When transferring to the audio stream of reading correspondence main or carry out audio frequency from player and play, the real-time judge player is needed
Global state mark.If main player or from player in halted state is played, the player be set suspend and play
Correspondence audio stream;If main player is in broadcasting halted state from player, the player is set and stops correspondence immediately
The broadcasting of audio stream.When audio frequency is commenced play out, the global state for arranging correspondence player is masked as playing shape master and slave player
State;At the end of playing audio frequency, then the global state for arranging correspondence player is masked as playing halted state, i.e. idle condition.
Above-mentioned correspondence master from player is judged by master and slave player status, if first audio frequency transfers to master
Player is played out, then main player is in seizure condition, and second audio frequency is just transferred to from player to play out;If main
Playing simultaneously from player, then showing principal and subordinate's player all in seizure condition, the audio frequency to be played such as the 3rd is just waiting it
In one play after transfer in principal and subordinate's player idle player to continue to play again.
S204, media_destroy (audio frequency destruction) interface for creating and realizing audio frequency destruction, by calling based on hardware
The audio frequency destroying method that the SDK of equipment is provided, release and destruction of the realization to the player used resource of establishment, and will create before
The audio file for building and being stored in internal memory is removed.
S205, other audio frequency play interfaces are created and realize, the corresponding SDK Broadcast Controls interface or side by combined with hardware equipment
Method is realized.Because KNI expansion interfaces are Java Virtual Machine unified definition, and for known, do not illustrate one by one here.For example:In wound
Need to be broadcasting halted state by corresponding player global state traffic sign placement when building media_pause (play and suspend) interface;
Need to be halted state by corresponding player global state traffic sign placement when media_stop (stopping playing) interface is created;
Realize the media_set_volume interfaces for arranging volume:By calling the volume of hardware device, function or side are set
Method, and the incoming volume parameter of the interface is configured as volume value.
S3, JSR135 parts are incorporated in Java Virtual Machine, generate and support that the Java that audio frequency is played and audio mixing is played is virtual
Machine client.
The embodiment of the present invention also provide it is a kind of for realize said method realize in Java Virtual Machine audio mixing play
System, including the related KNI expansion interface acquiring units of audio frequency, audio frequency play interface realize unit, Java Virtual Machine client
Signal generating unit, wherein:
The related KNI expansion interface acquiring units of audio frequency are used for:Obtained using the widening parts JSR135 of Java Virtual Machine
The KNI expansion interface related to audio frequency;
Audio frequency play interface realizes that unit is used for:According to the audio frequency correlation KNI expansion interfaces that JSR135 parts are provided, realize
The audio frequency play interface of hardware device, audio frequency play interface includes that audio frequency creates media_create interfaces, audio frequency and closes
Media_close interfaces, audio frequency release media_release_device interfaces, setting voice data media_do_
Buffering interfaces, startup audio frequency play media_start interfaces, stop playing media_stop interfaces, audio frequency destruction
Media_destroy interfaces;Hardware device is supported to create two players and played simultaneously, by the software based on hardware device
The audio frequency play interface is realized in development kit SDK extensions, initiating hardware equipment, creates main player, from player, real
The audio mixing of existing master and slave player plays control;
Java Virtual Machine client signal generating unit is used for:JSR135 parts are incorporated in Java Virtual Machine, are generated and is supported sound
The Java Virtual Machine client that frequency is played and audio mixing is played.
Audio frequency play interface realizes that unit realizes subelement, media_do_buffering including media_create interfaces
Interface realizes that subelement, media_start interfaces realize that subelement, other audio frequency play interfaces realize subelement, wherein:
Media_create interfaces realize that subelement is used for:Create and realize that the audio frequency for playing audio frequency creates media_
Create interfaces, the media_create interfaces are used for initiating hardware equipment, create main player and from player, and tie
Close media_create parameters and generate audio stream sign, by media_create parameter settings to pointer return value, to adjust
Used with incoming during other broadcast control methods;The global state mark of master and slave player is set:Broadcast state, time-out broadcast state
With broadcasting halted state;Media_create parameters include playerId, mimeType, mimeLength, wherein, playerId
Presentation medium plays sign, each audio frequency unique sign in gaming;MimeType represents audio types;MimeLength tables
Show the length of mimeType;Audio stream sign indicates playerId by media play and audio types mimeType are described
Sign.
Media_do_buffering interfaces realize that subelement is used for:Create and realize for arranging voice data
Media_do_buffering interfaces, incoming audio stream to be played is stored in internal memory, and from the incoming finger of Java Virtual Machine
Take out in pin and call the audio file name created during media_create interfaces, as the sign of the audio stream;Java Virtual Machine
Incoming pointer includes playing sign ID, audio stream total length, audio types, audio stream filename, wave formatted audio files
Channel number, bit rate and sample rate, wherein, play sign ID and represent that audio stream total length is represented with shaping, sound with long shaping
Frequency type is represented with shaping, for indicating the type of current audio stream;Audio stream filename represents with character type, is stored in internal memory
In or the read-write region of equipment in;Channel number, bit rate, the sample rate of wave formatted audio files is represented with shaping.
Media_start interfaces realize that subelement is used for:Create and realize the media_start for starting audio frequency broadcasting
Interface, according to the audio stream sign of the audio frequency to be played stored in the incoming pointer of Java Virtual Machine, creates separate threads, circulation
The incoming audio stream data of media_do_buffering interfaces is read, and is stored in the audio stream in internal memory and indicate corresponding sound
During frequency flows, transfer to correspondence main the audio stream of reading or carry out audio frequency broadcasting from player, the audio mixing for realizing master and slave player is broadcast
Put control.
Other audio frequency play interfaces realize that subelement is used for:Other audio frequency play interfaces are created and realize, it is hard by combining
The corresponding SDK Broadcast Controls interface of part equipment or method are realized:When broadcasting time-out media_pause interfaces are created, broadcast corresponding
Device global state traffic sign placement is put to play halted state;When stopping broadcasting media_stop interfaces are created, broadcast corresponding
Device global state traffic sign placement is put for halted state;Realize the media_set_volume interfaces for arranging volume:It is logical
Cross and call the volume of hardware device that function or method are set, and the incoming volume parameter of the interface is set as volume value
Put.
The principle of the embodiment of the present invention is elaborated as follows:
What the Java Virtual Machine that the embodiment of the present invention is adopted was provided for Sun Microsystems increase income Java Virtual Machine, its audio frequency is played
It is widening parts JSR135 (Java Specification Requests 135, the Java code requirements by Java Virtual Machine
135) realize, JSR135 is that Sun Microsystems are increased income the modular unit of Java Virtual Machine, it is public to be that Java standardization bodies submit to Sun
The Java exploitation drafts of department.JSR135 is realized based on the Audio Processing part of J2ME standards, and device-dependent KNI is played and connect
Mouth then needs terminal unit to be voluntarily extended realization.
The Audio Processing of Java Virtual Machine is realized on the basis of based on J2ME specifications, and is directed to audio stream and is passed through
It is all to need the KNI Interface Expandings based on JSR135 to realize that equipment carries out the method for final broadcasting, and its play operation is only stopped
Stay in the direct Broadcast Control to audio stream to operate.The present invention by extension JSR135 KNI interfaces, realize create main player and from
Player, allows Java game to realize that two-way audio can be possibly realized while playing, and avoids a broadcasting in prior art
The device reproduction of multiple audio streams incoming to upper strata Java Virtual Machine toggles broadcasting, and the audio frequency that is likely to result in is discontinuous or audio frequency with
The problems such as picture is mismatched.
Main player is created when realizing that audio frequency creates interface and from player, by the media play mark of currently playing parameter
Show storage in a pointer.When realizing arranging audio frequency data interface, upper strata Java Virtual Machine will be received and call the interface
And incoming audio stream is stored in internal memory or in equipment in the file in read-write region.By the incoming pointer of Java Virtual Machine
Media play sign is obtained, and the audio types generation with reference to belonging to audio stream identifies the audio file name of the audio frequency (such as
1001.wav).When realizing starting audio frequency play interface, media play sign is obtained according to the incoming pointer of Java Virtual Machine,
And create audio frequency play thread.The thread is obtained according to the Broadcast Control idle condition of principal and subordinate's player according to media play sign
The corresponding audio file in read-write region in the audio stream being stored in internal memory or equipment, is ceaselessly read and to hard by thread
Write to realize that audio frequency is played in the audio buffer district that part is specified.Current affiliated main player is reset in playing process or from broadcasting
The use state of device.
The Broadcast Control idle condition for judging principal and subordinate's player is for present video to be switched in master and slave player into idle shape
The player of state is played out.In audio frequency playing process, when media_pause (play suspend) is called, then the broadcasting thread
Suspend, and audio stream is write in the audio buffer district specified to hardware and suspend the function of playing to reach;When calling media_stop
When (stopping playing), then the broadcasting thread stops writing audio stream in the audio buffer district specified to hardware, and terminates to exit the line
Journey.
Those skilled in the art can carry out various modifications and variations to the embodiment of the present invention, if these modifications and change
Within the scope of the claims in the present invention and its equivalent technologies, then these modifications and modification are also in protection scope of the present invention for type
Within.
The prior art that the content not described in detail in description is known to the skilled person.
Claims (9)
1. it is a kind of that the method that audio mixing is played is realized in Java Virtual Machine, it is characterised in that to comprise the following steps:
S1, obtain the KNI expansion interface related to audio frequency using the widening parts JSR135 of Java Virtual Machine;
S2, the audio frequency correlation KNI expansion interfaces provided according to JSR135 parts, realize the audio frequency play interface of hardware device, institute
State audio frequency play interface and create media_create interfaces, audio frequency closing media_close interfaces, audio frequency release including audio frequency
Media_release_device interfaces, setting voice data media_do_buffering interfaces, startup audio frequency are played
Media_start interfaces, stopping are played media_stop interfaces, audio frequency and destroy media_destroy interfaces;Hardware device is supported
Create two players and play simultaneously, the audio frequency is realized by the SDK SDK extensions based on hardware device
Playback interface, initiating hardware equipment creates main player, from player, and the audio mixing for realizing master and slave player plays control;
S3, JSR135 parts are incorporated in Java Virtual Machine, generate the Java Virtual Machine visitor for supporting that audio frequency is played and audio mixing is played
Family end;
Realize that the flow process of the audio frequency play interface of hardware device is as follows described in step S2:
S201, create and realize that the audio frequency for playing audio frequency creates media_create interfaces, the media_create connects
Mouth generates audio stream for initiating hardware equipment, establishment main player and from player with reference to media_create parameters
Sign, by media_create parameter settings to pointer return value, to call incoming during other broadcast control methods use;Arrange
The global state mark of master and slave player:Broadcast state, time-out broadcast state and broadcasting halted state;
S202, the media_do_buffering interfaces for arranging voice data are created and realize, by incoming sound to be played
Frequency stream is stored in the audio file of internal memory, and when media_create interfaces are called in taking-up from Java Virtual Machine incoming pointer
The audio file name of establishment, as the sign of the audio stream;
S203, create and realize for start audio frequency broadcasting media_start interfaces, according to the incoming pointer of Java Virtual Machine
The audio stream sign of the audio frequency to be played of middle storage, creates separate threads, and circulation is read media_do_buffering interfaces and passed
The audio stream data for entering, and be stored in internal memory in the corresponding audio stream of audio stream sign, it is right that the audio stream of reading is transferred to
Should lead or carry out audio frequency broadcasting from player, the audio mixing for realizing master and slave player plays control;
S204, the media_destroy interfaces for creating and realizing audio frequency destruction, are provided by calling the SDK based on hardware device
Audio frequency destroying method, realize to create player used resource release and destruction, and will before create and be stored in internal memory
Audio file remove;
S205, other audio frequency play interfaces are created and realize, by the corresponding SDK Broadcast Controls interface or method reality of combined with hardware equipment
It is existing:When broadcasting time-out media_pause interfaces are created, corresponding player global state traffic sign placement is suspended into shape to play
State;It is halted state by corresponding player global state traffic sign placement when stopping broadcasting media_stop interfaces are created;It is real
Now it is used to arrange the media_set_volume interfaces of volume:By calling the volume of hardware device, function or side are set
Method, and the incoming volume parameter of the interface is configured as volume value.
2. the method that audio mixing is played is realized as claimed in claim 1 in Java Virtual Machine, it is characterised in that:In step S201
The media_create parameters include playerId, mimeType, mimeLength, wherein, playerId presentation mediums are broadcast
Sign is put, each audio frequency unique sign in gaming;MimeType represents audio types;MimeLength represents mimeType
Length;Audio stream sign indicates playerId by media play and audio types mimeType are described sign.
3. the method that audio mixing is played is realized as claimed in claim 1 in Java Virtual Machine, it is characterised in that:In step S202
The incoming pointer of the Java Virtual Machine include play sign ID, audio stream total length, audio types, audio stream filename,
The channel number of wave formatted audio files, bit rate and sample rate, wherein, play sign ID and represent that audio stream is total with long shaping
Length represents that audio types are represented with shaping with shaping, for indicating the type of current audio stream;Audio stream filename character
Type represents, be stored in internal memory or the read-write region of equipment in;The channel number of wave formatted audio files, bit rate, sampling
Rate is represented with shaping.
4. the method that audio mixing is played is realized as claimed in claim 1 in Java Virtual Machine, it is characterised in that:In step S203
When transferring to the audio stream of reading correspondence main or carry out audio frequency from player and play, the global state mark of the real-time judge player
Will, if main player or from player in halted state is played, the player be set suspend and play correspondence audio stream;Such as
Fruit main player is in broadcasting halted state from player, then arrange the broadcasting that the player stops immediately correspondence audio stream;
When audio frequency is commenced play out, the global state for arranging correspondence player is masked as broadcast state to master and slave player;Play audio frequency knot
Shu Shi, the then global state for arranging correspondence player is masked as playing halted state, i.e. idle condition.
5. the method that audio mixing is played is realized in Java Virtual Machine as any one of Claims 1-4, its feature exists
In:Master is corresponded to described in step S203 or carry out audio frequency to play from player is judged by master and slave player status, if
First audio frequency transfers to main player to play out, then main player is in seizure condition, and second audio frequency is just transferred to from broadcasting
Device is played out;If principal and subordinate's player is being played simultaneously, show principal and subordinate's player all in seizure condition, the 3rd wait
The audio frequency of broadcasting just waits one of them to transfer to player idle in principal and subordinate's player to continue to play after playing again.
6. it is used to realize the system that audio mixing player method is realized in Java Virtual Machine described in claim 1, its feature exists
In:Unit, the life of Java Virtual Machine client are realized including the related KNI expansion interface acquiring units of audio frequency, audio frequency play interface
Into unit, wherein:
The related KNI expansion interface acquiring units of the audio frequency are used for:Obtained using the widening parts JSR135 of Java Virtual Machine
The KNI expansion interface related to audio frequency;
The audio frequency play interface realizes that unit is used for:According to the audio frequency correlation KNI expansion interfaces that JSR135 parts are provided, realize
The audio frequency play interface of hardware device, the audio frequency play interface includes that audio frequency creates media_create interfaces, audio frequency and closes
Media_close interfaces, audio frequency release media_release_device interfaces, setting voice data media_do_
Buffering interfaces, startup audio frequency play media_start interfaces, stop playing media_stop interfaces, audio frequency destruction
Media_destroy interfaces;Hardware device is supported to create two players and played simultaneously, by the software based on hardware device
The audio frequency play interface is realized in development kit SDK extensions, initiating hardware equipment, creates main player, from player, real
The audio mixing of existing master and slave player plays control;
The Java Virtual Machine client signal generating unit is used for:JSR135 parts are incorporated in Java Virtual Machine, are generated and is supported sound
The Java Virtual Machine client that frequency is played and audio mixing is played.
7. the system that audio mixing is played is realized as claimed in claim 6 in Java Virtual Machine, it is characterised in that:The audio frequency is broadcast
Put interface and realize that unit realizes that subelement, media_do_buffering interfaces realize that son is single including media_create interfaces
Unit, media_start interfaces realize that subelement, other audio frequency play interfaces realize subelement, wherein:
The media_create interfaces realize that subelement is used for:Create and realize that the audio frequency for playing audio frequency creates media_
Create interfaces, the media_create interfaces are used for initiating hardware equipment, create main player and from player, and tie
Close media_create parameters and generate audio stream sign, by media_create parameter settings to pointer return value, to adjust
Used with incoming during other broadcast control methods;The global state mark of master and slave player is set:Broadcast state, time-out broadcast state
With broadcasting halted state;
The media_do_buffering interfaces realize that subelement is used for:Create and realize for arranging voice data
Media_do_buffering interfaces, incoming audio stream to be played is stored in internal memory, and from the incoming finger of Java Virtual Machine
Take out in pin and call the audio file name created during media_create interfaces, as the sign of the audio stream;
The media_start interfaces realize that subelement is used for:Create and realize the media_start for starting audio frequency broadcasting
Interface, according to the audio stream sign of the audio frequency to be played stored in the incoming pointer of Java Virtual Machine, creates separate threads, circulation
The incoming audio stream data of media_do_buffering interfaces is read, and is stored in the audio stream in internal memory and indicate corresponding sound
During frequency flows, transfer to correspondence main the audio stream of reading or carry out audio frequency broadcasting from player, the audio mixing for realizing master and slave player is broadcast
Put control;
Described other audio frequency play interfaces realize that subelement is used for:Other audio frequency play interfaces are created and realize, it is hard by combining
The corresponding SDK Broadcast Controls interface of part equipment or method are realized:When broadcasting time-out media_pause interfaces are created, broadcast corresponding
Device global state traffic sign placement is put to play halted state;When stopping broadcasting media_stop interfaces are created, broadcast corresponding
Device global state traffic sign placement is put for halted state;Realize the media_set_volume interfaces for arranging volume:It is logical
Cross and call the volume of hardware device that function or method are set, and the incoming volume parameter of the interface is set as volume value
Put.
8. the system that audio mixing is played is realized as claimed in claim 7 in Java Virtual Machine, it is characterised in that:The media_
Create parameters include playerId, mimeType, mimeLength, wherein, playerId presentation mediums play sign, each
Audio frequency unique sign in gaming;MimeType represents audio types;MimeLength represents the length of mimeType;Audio frequency
Fail to be sold at auction and show that indicating playerId and audio types mimeType by media play is described sign.
9. the system that audio mixing is played is realized as claimed in claim 7 in Java Virtual Machine, it is characterised in that:The Java is empty
The incoming pointer of plan machine includes playing sign ID, audio stream total length, audio types, audio stream filename, wave format audios
The channel number of file, bit rate and sample rate, wherein, play sign ID and represented with long shaping, audio stream total length shaping table
Show, audio types are represented with shaping, for indicating the type of current audio stream;Audio stream filename is represented with character type, stored
In internal memory or in the read-write region of equipment;Channel number, bit rate, the sample rate of wave formatted audio files uses shaping table
Show.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410454859.XA CN104269185B (en) | 2014-09-09 | 2014-09-09 | Method and system for realizing sound mixing play in Java virtual machine |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410454859.XA CN104269185B (en) | 2014-09-09 | 2014-09-09 | Method and system for realizing sound mixing play in Java virtual machine |
Publications (2)
Publication Number | Publication Date |
---|---|
CN104269185A CN104269185A (en) | 2015-01-07 |
CN104269185B true CN104269185B (en) | 2017-04-12 |
Family
ID=52160699
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410454859.XA Active CN104269185B (en) | 2014-09-09 | 2014-09-09 | Method and system for realizing sound mixing play in Java virtual machine |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN104269185B (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109032559B (en) * | 2018-07-25 | 2021-06-01 | 南京创维信息技术研究院有限公司 | Configuration method and system for sharing same recording equipment by multiple applications |
CN114302243A (en) * | 2021-11-30 | 2022-04-08 | 四川天邑康和通信股份有限公司 | Method for realizing operation of J2ME game audio file by IPTV set-top box |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101442586A (en) * | 2008-12-31 | 2009-05-27 | 中兴通讯股份有限公司 | Method and terminal for playing multimedia |
US7668936B1 (en) * | 2000-05-26 | 2010-02-23 | Krikorian Thomas M | Continuous media playback system controlled over a distributed communication system |
CN101853680A (en) * | 2004-12-01 | 2010-10-06 | 松下电器产业株式会社 | Transcriber and reproducting method |
-
2014
- 2014-09-09 CN CN201410454859.XA patent/CN104269185B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7668936B1 (en) * | 2000-05-26 | 2010-02-23 | Krikorian Thomas M | Continuous media playback system controlled over a distributed communication system |
CN101853680A (en) * | 2004-12-01 | 2010-10-06 | 松下电器产业株式会社 | Transcriber and reproducting method |
CN101442586A (en) * | 2008-12-31 | 2009-05-27 | 中兴通讯股份有限公司 | Method and terminal for playing multimedia |
Non-Patent Citations (1)
Title |
---|
JSR135的设计与实现;陆芸芸等;《计算机工程与应用》;20061021(第30期);第111-113、133页 * |
Also Published As
Publication number | Publication date |
---|---|
CN104269185A (en) | 2015-01-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
Brinkmann et al. | Embedding pure data with libpd | |
CN102568517B (en) | Interfaces for digital media processing | |
CN104333808A (en) | General player applied to Android and Linux smart televisiosn | |
JP2010288301A (en) | System for multimedia rendering in portable device | |
JPH09502821A (en) | Object-oriented audio system | |
US20050262254A1 (en) | Dynamic redirection of streaming media between computing devices | |
JPH09503070A (en) | Object-oriented MIDI system | |
JPH09503080A (en) | Multimedia data routing system | |
JPH09503081A (en) | Object-oriented video system | |
TW200405703A (en) | System for multimedia rendering in a portable device | |
CN104516709B (en) | Voice householder method and system based on running software scene and voice assistant | |
CN104732989B (en) | Intelligent music broadcasting control system and its control method | |
WO2018126613A1 (en) | Method for playing audio data and dual-screen mobile terminal | |
WO2003081436A1 (en) | Browser and program containing multi-medium content | |
CN103648037A (en) | Intelligent television media player and search response method thereof, and intelligent television | |
CN101304496A (en) | Method for implementing mobile phone television based on JAVA | |
CN107071541A (en) | The method and apparatus managed for peripheral context | |
CN104269185B (en) | Method and system for realizing sound mixing play in Java virtual machine | |
Wyatt et al. | Animated music notation on the iPad | |
CN101753793A (en) | Method for realizing interactive interface in embedded set top box system | |
CN101483694B (en) | Playing control method and apparatus for vector animation | |
US7934159B1 (en) | Media timeline | |
CN108600813A (en) | a kind of media file playing method, device and media play system | |
CN109669691A (en) | Platform universal control method and system based on built-in Linux audio player | |
CN103701854A (en) | Network real-time audio transmission method based on application virtualization |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |