{"id":296862,"date":"2020-01-08T15:00:11","date_gmt":"2020-01-08T15:00:11","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=296862"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=296862","title":{"rendered":"\u0417\u0430\u043f\u0438\u0441\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0437\u0432\u0443\u043a\u0430 \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 Multipeer Connectivity"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483174\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/eg\/ah\/sa\/egahsainzphs5fo7hefrl3dlptm.png\"><br \/>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0434\u0440\u043e\u0433\u043e\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c! \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0437\u0432\u0443\u043a \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e. \u041a\u0430\u043a \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u0432\u0443\u043a\u0430 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <b>MultipeerConnectivity<\/b>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0432\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0437\u0432\u0443\u043a\u0430. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<h2>\u0417\u0430\u043f\u0438\u0441\u044c \u0430\u0443\u0434\u0438\u043e \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/h2>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0430\u0443\u0434\u0438\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <b>AVAudioEngine<\/b> \u0438 <b>AVAudioMixerNode<\/b> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c <b>AVFoundation<\/b>.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0438\u0441\u0438 \u0430\u0443\u0434\u0438\u043e:<\/p>\n<pre><code class=\"swift\">final class Recorder {          private let engine = AVAudioEngine()     private let mixer = AVAudioMixerNode()          var onRecordedAction: ((Data) -&gt; Void)?          init() {         setupAudioSession()     }          private func setupAudioSession() {         let audioSession = AVAudioSession.sharedInstance()         do {             try audioSession.setCategory(.record)             try audioSession.setMode(.measurement)             try audioSession.setActive(true)         } catch {             debugPrint(error.localizedDescription)         }     }          func startRecording() {         let input = engine.inputNode         let inputFormat = input.outputFormat(forBus: 0)         engine.attach(mixer)         engine.connect(input, to: mixer, format: inputFormat)         mixer.installTap(onBus: 0, bufferSize: 1024, format: mixer.outputFormat(forBus: 0)) { [weak self] buffer, _ in             self?.onRecordedAction?(buffer.data)         }         engine.prepare()         do {             try engine.start()         } catch {             debugPrint(error.localizedDescription)         }     }          func stopRecording() {         engine.stop()     } } <\/code><\/pre>\n<p>  \u0412 \u043e\u0431\u0449\u0435\u043c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e, \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043c\u0438\u043a\u0441\u0435\u0440\u0430 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0438\u0445 \u0432 \u043d\u0430\u0448\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u044e onRecodedAction. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0434\u0430\u043b\u044c\u0448\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u043c\u0438 \u0430\u0443\u0434\u0438\u043e, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 data. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 extension.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f <b>PCMBuffer<\/b> \u0432 <b>Data<\/b>:<\/p>\n<pre><code class=\"swift\">extension AVAudioPCMBuffer {     var data: Data {         let channels = UnsafeBufferPointer(start: floatChannelData, count: 1)         let data = Data(bytes: channels[0], count: Int(frameCapacity * format.streamDescription.pointee.mBytesPerFrame))         return data     } } <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0412\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0430\u0443\u0434\u0438\u043e<\/h2>\n<p>  \u0414\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0430\u0443\u0434\u0438\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0432\u0441\u0435 \u0442\u043e\u0442 \u0436\u0435 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a, \u0432 \u0438\u0442\u043e\u0433\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u0432 \u0434\u0432\u0443\u0445 \u0441\u043b\u043e\u0432\u0430\u0445, \u0442\u043e \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c node \u0438 \u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u043c \u0435\u0435 \u0437\u0430 engine, \u0434\u0430\u043b\u044c\u0448\u0435 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0448\u0443 data \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 <b>PCMBuffer<\/b> \u0438 \u043e\u0442\u0434\u0430\u0435\u043c \u043d\u0430\u0448\u0435\u0439 node \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"swift\">final class Player {          private let engine = AVAudioEngine()     private var playerNode = AVAudioPlayerNode()          init() {         setupAudioSession()     }          private func setupAudioSession() {         let audioSession = AVAudioSession.sharedInstance()         do {             try audioSession.setCategory(.playback)             try audioSession.setActive(true)         } catch {             debugPrint(error.localizedDescription)         }     }          private func setupPlayer(buffer: AVAudioPCMBuffer) {         engine.attach(playerNode)         engine.connect(playerNode, to: engine.mainMixerNode, format: buffer.format)         engine.prepare()     }          private func tryStartEngine() {         do {             try engine.start()         } catch {             debugPrint(error.localizedDescription)         }     }          func addPacket(packet: Data) {         guard let format = AVAudioFormat.common, let buffer = packet.pcmBuffer(format: format) else {             debugPrint(\"Cannot convert buffer from Data\")             return         }         if !engine.isRunning {             setupPlayer(buffer: buffer)             tryStartEngine()             playerNode.play()         }         playerNode.volume = 1         playerNode.scheduleBuffer(buffer, completionHandler: nil)     } } <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 extension \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 <b>Data<\/b> \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0432 <b>PCMBuffer<\/b> \u0438 \u043d\u0430\u0448\u0435\u0433\u043e <b>AVAudioFormat<\/b> \u0434\u043b\u044f \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0430\u0443\u0434\u0438\u043e:<\/p>\n<pre><code class=\"swift\">private extension Data {      func pcmBuffer(format: AVAudioFormat) -&gt; AVAudioPCMBuffer? {         let streamDesc = format.streamDescription.pointee         let frameCapacity = UInt32(count) \/ streamDesc.mBytesPerFrame         guard let buffer = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: frameCapacity) else { return nil }         buffer.frameLength = buffer.frameCapacity         let audioBuffer = buffer.audioBufferList.pointee.mBuffers         withUnsafeBytes { addr in             guard let baseAddress = addr.baseAddress else {                 return             }             audioBuffer.mData?.copyMemory(from: baseAddress, byteCount: Int(audioBuffer.mDataByteSize))         }         return buffer     } }  extension AVAudioFormat {     static let common = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 44100, channels: 1, interleaved: false) } <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u0443\u0434\u0438\u043e \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e<\/h2>\n<p>  \u041d\u0443 \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446-\u0442\u043e \u043c\u044b \u043f\u043e\u0434\u043e\u0448\u043b\u0438 \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0433\u043b\u0430\u0432\u043d\u043e\u043c\u0443 \u2014 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0430 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u0443\u0434\u0438\u043e \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <b>MultipeerConnectivity<\/b>. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 <b>MCPeerID<\/b> (\u0411\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u0430\u0448\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e) \u0438 \u0434\u0432\u0430 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 <b>MCNearbyServiceAdvertiser<\/b> \u0438 <b>MCNearbyServiceBrowser<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0438 \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0440\u0443\u0433\u0438\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043c\u043e\u0433\u043b\u0438 \u043d\u0430\u0441 \u043d\u0430\u0439\u0442\u0438 (\u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043e\u0442 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435). \u0422\u0430\u043a \u0436\u0435 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0435\u0441\u0441\u0438\u044e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u0430\u0443\u0434\u0438\u043e \u0438 \u00ab\u043c\u0430\u043d\u0438\u043f\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u00bb \u043d\u0430\u0448\u0438\u043c\u0438 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445:<\/p>\n<pre><code class=\"swift\">private struct Constants {     static var serviceType = \"bn-radio\"     static var timeOut: Double = 10 }  final class Connectivity: NSObject {          private var advertiser: MCNearbyServiceAdvertiser? = nil     private var browser: MCNearbyServiceBrowser? = nil     private let peerID: MCPeerID     private let session: MCSession     private var invitationHandler: ((Bool, MCSession) -&gt; Void)? = nil          var onDeviceFoundedAction: ((MCPeerID) -&gt; Void)?     var onDeviceLostedAction: ((MCPeerID) -&gt; Void)?     var onInviteAction: ((MCPeerID) -&gt; Void)?     var onConnectingAction: (() -&gt; Void)?     var onConnectedAction: (() -&gt; Void)?     var onDisconnectedAction: (() -&gt; Void)?     var onPacketReceivedAction: ((Data) -&gt; Void)?          init(deviceID: String) {         peerID = MCPeerID(displayName: deviceID)         session = MCSession(peer: peerID, securityIdentity: nil, encryptionPreference: .none)         super.init()         session.delegate = self     }          func startHosting() {         advertiser = MCNearbyServiceAdvertiser(peer: peerID, discoveryInfo: nil, serviceType: Constants.serviceType)         advertiser?.delegate = self         advertiser?.startAdvertisingPeer()     }          func findHost() {         browser = MCNearbyServiceBrowser(peer: peerID, serviceType: Constants.serviceType)         browser?.delegate = self         browser?.startBrowsingForPeers()     }          func stop() {         advertiser?.stopAdvertisingPeer()         browser?.stopBrowsingForPeers()     }          func invite(peerID: MCPeerID) {         browser?.invitePeer(peerID, to: session, withContext: nil, timeout: Constants.timeOut)     }          func handleInvitation(isAccepted: Bool) {         invitationHandler?(isAccepted, session)     }          func send(data: Data) {         try? self.session.send(data, toPeers: session.connectedPeers, with: .unreliable)     } }  extension Connectivity: MCSessionDelegate {          func session(_ session: MCSession, peer peerID: MCPeerID, didChange state: MCSessionState) {         switch state {         case .connecting:             onConnectingAction?()         case .connected:             onConnectedAction?()         case .notConnected:             onDisconnectedAction?()         @unknown default:             debugPrint(\"Error during session state changed on: \\(state)\")         }     }          func session(_ session: MCSession, didReceive data: Data, fromPeer peerID: MCPeerID) {         onPacketReceivedAction?(data)     }          func session(_ session: MCSession, didReceive stream: InputStream, withName streamName: String, fromPeer peerID: MCPeerID) {              }          func session(_ session: MCSession, didStartReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, with progress: Progress) {              }          func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL?, withError error: Error?) {              }          func session(_ session: MCSession, didReceiveCertificate certificate: [Any]?, fromPeer peerID: MCPeerID, certificateHandler: @escaping (Bool) -&gt; Void) {         certificateHandler(true)     } }  extension Connectivity: MCNearbyServiceAdvertiserDelegate {          func advertiser(_ advertiser: MCNearbyServiceAdvertiser, didReceiveInvitationFromPeer peerID: MCPeerID, withContext context: Data?, invitationHandler: @escaping (Bool, MCSession?) -&gt; Void) {         self.invitationHandler = invitationHandler         onInviteAction?(peerID)     } }  extension Connectivity: MCNearbyServiceBrowserDelegate {          func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String : String]?) {         onDeviceFoundedAction?(peerID)     }          func browser(_ browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID) {         onDeviceLostedAction?(peerID)     } } <\/code><\/pre>\n<p>  \u0412\u0435\u0441\u044c \u043a\u043e\u0434 \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0435 \u0432\u044b\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0430\u043c\u043e\u0439 \u0441\u0443\u0442\u0438 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435. \u042f \u0441\u043e\u0433\u043b\u0430\u0441\u0435\u043d, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0435\u0449\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u043d\u043e \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u043f\u043e\u0434\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043d\u0443\u0436\u0435\u043d \u043c\u043d\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. <\/p>\n<p>  \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f <b>MultipeerConnectivity<\/b> \u0431\u044b\u043b\u0438 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u044b \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0434\u0438\u0441\u0442\u0430\u043d\u0446\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u044f \u043d\u0435 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441\u0445\u043e\u0436\u0435\u0435 \u0441 \u0430\u0443\u0434\u0438\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e\u0439 \u043e\u0441\u043d\u043e\u0432\u0435.<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/483174\/\"> https:\/\/habr.com\/ru\/post\/483174\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/483174\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/eg\/ah\/sa\/egahsainzphs5fo7hefrl3dlptm.png\"><br \/>  \u0414\u043e\u0431\u0440\u044b\u0439 \u0434\u0435\u043d\u044c, \u0434\u0440\u043e\u0433\u043e\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c! \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 \u044f \u0440\u0435\u0448\u0438\u043b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0437\u0432\u0443\u043a \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e. \u041a\u0430\u043a \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0433\u043e \u0437\u0432\u0443\u043a\u0430 \u0432\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a <b>MultipeerConnectivity<\/b>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>  \u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0432\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0437\u0432\u0443\u043a\u0430. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439.<\/p>\n<h2>\u0417\u0430\u043f\u0438\u0441\u044c \u0430\u0443\u0434\u0438\u043e \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0438<\/h2>\n<p>  \u0414\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0430\u0443\u0434\u0438\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <b>AVAudioEngine<\/b> \u0438 <b>AVAudioMixerNode<\/b> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c <b>AVFoundation<\/b>.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-296862","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=296862"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/296862\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}