CN107770584A - A kind of method of the projection Android device screen picture to other platforms in real time - Google Patents

A kind of method of the projection Android device screen picture to other platforms in real time Download PDF

Info

Publication number
CN107770584A
CN107770584A CN201711058965.6A CN201711058965A CN107770584A CN 107770584 A CN107770584 A CN 107770584A CN 201711058965 A CN201711058965 A CN 201711058965A CN 107770584 A CN107770584 A CN 107770584A
Authority
CN
China
Prior art keywords
encoder
data
screen
real time
projection
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.)
Pending
Application number
CN201711058965.6A
Other languages
Chinese (zh)
Inventor
刘晓东
曾晓文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Net Technology Co Ltd
Original Assignee
Shenzhen Net Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shenzhen Net Technology Co Ltd filed Critical Shenzhen Net Technology Co Ltd
Priority to CN201711058965.6A priority Critical patent/CN107770584A/en
Publication of CN107770584A publication Critical patent/CN107770584A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/41Structure of client; Structure of client peripherals
    • H04N21/4104Peripherals receiving signals from specially adapted client devices
    • H04N21/4122Peripherals receiving signals from specially adapted client devices additional display device, e.g. video projector
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0481Interaction techniques based on graphical user interfaces [GUI] based on specific properties of the displayed interaction object or a metaphor-based environment, e.g. interaction with desktop elements like windows or icons, or assisted by a cursor's changing behaviour or appearance
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/14Digital output to display device ; Cooperation and interconnection of the display device with other functional units
    • G06F3/1407General aspects irrespective of display type, e.g. determination of decimal point position, display with fixed or driving decimal point, suppression of non-significant zeros
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/14Digital output to display device ; Cooperation and interconnection of the display device with other functional units
    • G06F3/1454Digital output to display device ; Cooperation and interconnection of the display device with other functional units involving copying of the display data of a local workstation or window to a remote workstation or window so that an actual copy of the data is displayed simultaneously on two or more displays, e.g. teledisplay
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/70Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by syntax aspects related to video coding, e.g. related to compression standards
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/436Interfacing a local distribution network, e.g. communicating with another STB or one or more peripheral devices inside the home
    • H04N21/43615Interfacing a Home Network, e.g. for connecting the client to a plurality of peripherals

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

The invention discloses a kind of Android device screen picture of projection in real time to the method for other platforms, comprise the following steps:(1), android equipment applies for screen capture authority to user;(2) encoder, arrange parameter, are initialized, bit rate and resolution ratio need user oneself to set, and program has default value, and to adapt to various network environments, screen capture dpi, which is arranged to minimum, can reduce data volume;(3) encoder and screen, are bound;The present invention can project android device screens in real time to equipment such as any, mac, picture links up, definition is high, transmission is stable, it is low to take mobile phone running memory, occupies that mobile phone cpu is low, and transmitted data amount is small compared with other schemes, data can be sent with screen rotation without black surround, various network environments are adapted to according to parameter setting.

Description

A kind of method of the projection Android device screen picture to other platforms in real time
Technical field
The present invention relates to projective technique, specifically a kind of projection Android device screen picture in real time to other platforms Method.
Background technology
Present what is become increasingly abundant, more and more with mobile device, performance is become better and better, the office of many people, all It has been transferred in mobile device, so, the timely projection function demand of mobile terminal is very urgent.Traditional scheme is using interception Picture, picture transfer to miscellaneous equipment, then parses picture, and show a sheet by a sheet one by one.But such mode has one The shortcomings that obvious, during being exactly a sheet by a sheet transmission, if picture is relatively more coherent, and mobile phone is carrying out cpu's during collection During high loaded process, the picture of transmitting procedure will special interim card, discontinuously, and be not " real-time " projection, to Consumer's Experience and The effect of demonstration has negative effect, it is necessary to improve.
The content of the invention
It is an object of the invention to provide it is a kind of in real time projection Android device screen picture to other platforms method with Solve the problems, such as to propose in above-mentioned background technology.
To achieve the above object, the present invention provides following technical scheme:
A kind of Android device screen picture of projection in real time comprises the following steps to the method for other platforms:
(1), android equipment applies for screen capture authority to user;
(2) encoder, arrange parameter, are initialized, bit rate and resolution ratio need user oneself to set, and program has acquiescence Value, to adapt to various network environments, screen capture dpi, which is arranged to minimum, can reduce data volume;
(3) encoder and screen, are bound;
(4), using encoder, on-screen data is converted into H264 data flows;
(5), by each frame h264 data all segment processings and it is sent to, the equipment such as mac, avoids memory overflow;
(6) screen rotation, is monitored, stops after rotation and discharges encoder, is repeated (2), (3), (4), (5) operation.
As the further scheme of the present invention:The application screen capture authority process of the step (1) is to pass through android The MediaProjectionManager of system manages class to apply for what is realized.
As the further scheme of the present invention:, it is necessary to the parameter that will be set in the encoder initialization of the step (2) It is stored in MediaFormat objects, and is configured in encoder.
As the further scheme of the present invention:The binding procedure of step (3), it is necessary to using encoder Surface objects, And VirtualDisplay objects are created, the surface objects of encoder are put into VirtualDisplay.
As the further scheme of the present invention:The transfer process of step (4) because before configuration codes device when set Parameter is H264 data, so herein only needing to take out the data that data are H264 forms.
As the further scheme of the present invention:The fragmentation procedure of step (5) is, it is necessary to by the ByteBuffer got Data sectional takes out, because ByteBuffer data are stored in bottom, being once fetched into Java layers can make using occupying internal memory It is too high, and plus the reason for the backstage, causing that using easily recovery, segmentation acquisition this kind of situation can be avoided.
As the further scheme of the present invention:The snoop procedure of step (6), screen can be obtained after a frame data are distributed Curtain direction, judges whether and consistent before, if inconsistent, just stop encoder and discharges, repeatedly (2), (3), (4), (5) are grasped Make.
Compared with prior art, the beneficial effects of the invention are as follows:The present invention can project android device screens in real time and arrive Arbitrarily, the equipment such as mac, picture link up, and definition is high, and transmission is stable, and it is low to take mobile phone running memory, and it is low to occupy mobile phone cpu, passes Transmission of data amount is small compared with other schemes, and data can be sent with screen rotation without black surround, various networks are adapted to according to parameter setting Environment.
Brief description of the drawings
Fig. 1 is the flow chart of the present invention.
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 describes, it is clear that described embodiment is only part of the embodiment of the present invention, rather than whole embodiments.It is based on Embodiment in the present invention, those of ordinary skill in the art are obtained all other under the premise of creative work is not made Embodiment, belong to the scope of protection of the invention.
Referring to Fig. 1, in the embodiment of the present invention, a kind of projection Android device screen picture in real time to other platforms Method,
Comprise the following steps:
Step (1), android equipment apply for screen capture authority to user;(2), initialization encoder, arrange parameter, Bit rate and resolution ratio need user oneself to set, and program has default value, to adapt to various network environments, screen capture dpi Data volume can be reduced by being arranged to minimum;(3) encoder and screen, are bound;(4), using encoder, on-screen data is converted to H264 data flows;(5), by each frame h264 data all segment processings and it is sent to, the equipment such as mac, avoids memory overflow;(6)、 Screen rotation is monitored, stops after rotation and discharges encoder, is repeated (2), (3), (4), (5) operation;
The application screen capture authority process of step (1), because, it is necessary to apply for that screen recording is weighed before obtaining on-screen data Limit, no authority, which may result in, can not obtain on-screen data.The MediaProjectionManager of Android system can be passed through Class is managed to apply capturing screen authority.
, it is necessary to which the parameter set is stored in MediaFormat objects in the encoder initialization of step (2), and It is configured in encoder.
The binding procedure of step (3), it is necessary to using encoder Surface objects, and create VirtualDisplay pairs As the surface objects of encoder are put into VirtualDisplay.
The transfer process of step (4) because before configuration codes device when there is provided parameter be H264 data, Only need to take out the data that data are H264 forms herein.
The fragmentation procedure of step (5), it is necessary to the data sectional in the ByteBuffer got is taken out because ByteBuffer data are stored in bottom, be once fetched into Java layers can make it is too high using internal memory is occupied, and plus on backstage The reason for, cause that using easily recovery, segmentation acquisition this kind of situation can be avoided.
The snoop procedure of step (6), it can obtain screen orientation after a frame data are distributed, judge whether the previous of sum Cause, if inconsistent, just stop encoder and discharge, repeat (2), (3), (4), (5) operation.
The present invention operation principle be:It is a kind of in real time projection Android device screen picture to other platforms method,
Comprise the following steps:
Step (1) is in the MediaProjectionManager classes by Android system CreateScreenCaptureIntent methods shield the application of authority to realize to record, after user, which clicks on, to be confirmed, can adjust back OnActivityResult in Activity, you can obtain MediaProjection objects.
Initialization encoder in step (2) is specifically the hard encoder MediaCodec carried using Android system, One is built first by the createVideoFormat methods in the MediaFormat classes in Android system MediaFormat objects, MIMETYPE are arranged to MediaFormat.MIMETYPE_VIDEO_AVC and show that data are h264 lattice Formula, and the resolution ratio thrown and shielded is set, because data source is in screen capture, so setting the KEY_ in MediaFormat COLOR_FORMAT parameters must be arranged to MediaCodecInfo.CodecCapabilities.COLOR_ It FormatSurface, can be malfunctioned when otherwise encoder configures, arrange parameter KEY_BIT_RATE can be continued to set bit rate, Parameter KEY_BITRATE_MODE is sets bit-rate mode, respectively MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CQ ensures quality, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_VBR dynamic bit rates, MediaCodecInfo.EncoderCapabilities.BITRATE_MODE_CBR constant bit rates, it is bad in network condition In the case of recommend dynamic bit rate pattern, guarantee quality mode, parameter are recommended in the case of network condition is preferable For KEY_FRAME_RATE to set frame number, parameter KEY_I_FRAME_INTERVAL is to set key frame interval, minimum 1, bear Number is except the first frame does not have key frame subsequently, it is proposed that is set to 1, part type, which is set to negative data, can be caused to spend screen, and parameter is set After putting, MediaFormat objects also finish with regard to structure, reuse in Android system in MediaCodec classes CreateEncoderByType methods, parameter are continuing with MediaFormat.MIMETYPE_VIDEO_AVC and show that data are H264 forms, and go to have configured hard encoder using the configure methods in newly-built MediaCodec.
The binding encoder and screen of step (3), it is in the MediaCodec objects built using step (2) CreateInputSurface methods, a Surface object is obtained, obtained in using step (1) CreateVirtualDisplay methods in MediaProjection objects are output data in the Surface of hard coded, This completes the binding of screen and hard encoder.
Step (4), which needs to circulate, takes out the compiled H264 formatted datas of hard encoder.A circulation is built first, as long as Do not stop projecting, just circulate always, then by the MediaCodec objects of step (2) structure DequeueOutputBuffer methods go to obtain data directory.If the index of return is more than 0, illustrate that data can be taken out, after The continuous incoming index just got of the getOutputBuffer methods used in MediaCodec objects, can be to obtain ByteBuffer objects, data are just in this object.
The data sectional that step (5) needs to get step (4) is sent because hard encoder have caused data compared with Greatly, application memory spilling is easily caused, and triggers collapse, so the data in the ByteBuffer objects that step (4) is got are not It can once take out, using in ByteBuffer objects, get methods, once only take out the data of regular length.Such as 10kb, if Insufficient length, then all take out.
Step (6) switches horizontal/vertical screen, then first stops and discharge hard encoder, repeat (2) if user's rotating mobile, (3), (4), (5) operation, untill projection finishes.

Claims (7)

1. a kind of method of the projection Android device screen picture to other platforms in real time, it is characterised in that including following step Suddenly:
(1) android equipment applies for screen capture authority to user;
(2) encoder, arrange parameter are initialized, bit rate and resolution ratio need user oneself to set, and program has default value, so as to Various network environments are adapted to, screen capture dpi, which is arranged to minimum, can reduce data volume;
(3) encoder and screen are bound;
(4) encoder is utilized, on-screen data is converted into H264 data flows;
(5) by each frame h264 data all segment processings and it is sent to, the equipment such as mac, avoids memory overflow;
(6) screen rotation is monitored, stops after rotation and discharges encoder, is repeated (2), (3), (4), (5) operation.
2. for a kind of projection Android device screen picture in real time according to claim 1 to the method for other platforms, it is special Sign is that the application screen capture authority process of the step (1) is by Android system MediaProjectionManager manages class to apply for what is realized.
3. for a kind of projection Android device screen picture in real time according to claim 1 to the method for other platforms, it is special Sign is, it is necessary to which the parameter set is stored in MediaFormat objects in the encoder initialization of the step (2), And it is configured in encoder.
4. for a kind of projection Android device screen picture in real time according to claim 1 to the method for other platforms, it is special Sign is, the binding procedure of step (3), it is necessary to using encoder Surface objects, and create VirtualDisplay pairs As the surface objects of encoder are put into VirtualDisplay.
5. for a kind of projection Android device screen picture in real time according to claim 1 to the method for other platforms, it is special Sign is, the transfer process of step (4) because before configuration codes device when there is provided the data that parameter is H264, Only need to take out the data that data are H264 forms herein.
6. for a kind of projection Android device screen picture in real time according to claim 1 to the method for other platforms, it is special Sign is, the fragmentation procedure of step (5), it is necessary to the data sectional in the ByteBuffer got is taken out because ByteBuffer data are stored in bottom, be once fetched into Java layers can make it is too high using internal memory is occupied, and plus on backstage The reason for, cause that using easily recovery, segmentation acquisition this kind of situation can be avoided.
7. for a kind of projection Android device screen picture in real time according to claim 1 to the method for other platforms, it is special Sign is, the snoop procedure of step (6), can obtain screen orientation after a frame data are distributed, judge whether the previous of sum Cause, if inconsistent, just stop encoder and discharge, repeat (2), (3), (4), (5) operation.
CN201711058965.6A 2017-11-01 2017-11-01 A kind of method of the projection Android device screen picture to other platforms in real time Pending CN107770584A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711058965.6A CN107770584A (en) 2017-11-01 2017-11-01 A kind of method of the projection Android device screen picture to other platforms in real time

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711058965.6A CN107770584A (en) 2017-11-01 2017-11-01 A kind of method of the projection Android device screen picture to other platforms in real time

Publications (1)

Publication Number Publication Date
CN107770584A true CN107770584A (en) 2018-03-06

Family

ID=61272336

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711058965.6A Pending CN107770584A (en) 2017-11-01 2017-11-01 A kind of method of the projection Android device screen picture to other platforms in real time

Country Status (1)

Country Link
CN (1) CN107770584A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110366028A (en) * 2018-04-10 2019-10-22 腾讯科技(深圳)有限公司 Screen video acquisition methods and device
CN112653913A (en) * 2020-12-25 2021-04-13 深圳市网旭科技有限公司 Screen projection method and device, client device and readable storage medium
CN114584816A (en) * 2020-11-30 2022-06-03 上海新微技术研发中心有限公司 Android screen projection definition setting method, computer-readable storage medium and equipment
CN114584828A (en) * 2020-11-30 2022-06-03 上海新微技术研发中心有限公司 Android screen projection method, computer-readable storage medium and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103248849A (en) * 2012-02-09 2013-08-14 株式会社理光 Image display apparatus and image display method
CN103442071A (en) * 2013-08-30 2013-12-11 华南理工大学 Mobile phone screen content real-time sharing method
WO2014017964A2 (en) * 2012-07-27 2014-01-30 Magine Holding AB A system and a method adapted to display epg media content from the world wide web

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103248849A (en) * 2012-02-09 2013-08-14 株式会社理光 Image display apparatus and image display method
WO2014017964A2 (en) * 2012-07-27 2014-01-30 Magine Holding AB A system and a method adapted to display epg media content from the world wide web
CN103442071A (en) * 2013-08-30 2013-12-11 华南理工大学 Mobile phone screen content real-time sharing method

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
CODE ISSUER: "横竖屏切换SurfaceView大小的调整", 《CSDN》 *
一叶知秋DONG: "Android5.0以上使用MediaProjection截图和录屏", 《CSDN》 *
云鹤起舞: "ffmpeg多种码率控制方式的实现", 《CSDN》 *
小蜜锋: "java读取超大文件方法 利用缓冲区分段读取 防止内存溢出异常", 《YUNCODE》 *
每天想睡16小时: "Android录屏通过udp共享到其它手机", 《CSDN》 *

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110366028A (en) * 2018-04-10 2019-10-22 腾讯科技(深圳)有限公司 Screen video acquisition methods and device
CN114584816A (en) * 2020-11-30 2022-06-03 上海新微技术研发中心有限公司 Android screen projection definition setting method, computer-readable storage medium and equipment
CN114584828A (en) * 2020-11-30 2022-06-03 上海新微技术研发中心有限公司 Android screen projection method, computer-readable storage medium and device
CN114584828B (en) * 2020-11-30 2024-05-17 上海新微技术研发中心有限公司 Android screen-throwing method, computer readable storage medium and equipment
CN112653913A (en) * 2020-12-25 2021-04-13 深圳市网旭科技有限公司 Screen projection method and device, client device and readable storage medium

Similar Documents

Publication Publication Date Title
CN107770584A (en) A kind of method of the projection Android device screen picture to other platforms in real time
CN105472477B (en) A kind of data transmission method, device and equipment
DE60028437T2 (en) Data transmitting and receiving apparatus and method for a digital mobile station
CN103647954B (en) Mobile video monitor system based on 3G channels Yu intelligent terminal
CN110121112A (en) A kind of video playing control method based on browser, system and device
CN106303329A (en) Record screen live broadcasting method and device, mobile device and live broadcast system
CN105681827B (en) Poster generation method, system and the relevant apparatus of direct broadcast band
CN103650431B (en) Method of transmitting video data and device
CN103414890B (en) The implementation method of remote desktop and device
CN103873812B (en) Self-adaptation resolution ratio H.264 video coding method of dispatching desk of broadband multimedia trunking system
CN102547375A (en) Transmission method for quickly previewing H.264 coded picture
CN108093197A (en) For the method, system and machine readable media of Information Sharing
CN103595965B (en) The mobile video monitoring method controlled based on video flow
CN103458087A (en) Remote mobile phone test experiencing method based on RTMP
CN106488243A (en) A kind of many description screen content method for video coding
CN103716648A (en) Information transmission method for remote teaching system and remote teaching system
CN102685472A (en) Method, device and system of data transmission
CN102202210A (en) Method for mobile phone to play real-time monitoring video and mobile phone to play real-time monitoring video
CN106210443B (en) The method that network-control shows content synchronization
CN106851172A (en) The call method of camera, apparatus and system
CN102263942A (en) Scalable video transcoding device and method
CN103248830A (en) Real-time video combination method for augmented reality scene of mobile intelligent terminal
CN106454388A (en) Method and device for determining live broadcast setting information
CN106331716A (en) Video compression method and device
CN108632679A (en) A kind of method of multi-medium data transmission and a kind of regarding networked terminals

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20180306