diff --git a/addons/chan_mobile.c b/addons/chan_mobile.c
index e0f95e175c27ff2254cf0312357a6fc21bf885e0..31d7f52bdc53d76685bc29dd50308375970dea1d 100644
--- a/addons/chan_mobile.c
+++ b/addons/chan_mobile.c
@@ -845,10 +845,10 @@ static struct ast_channel *mbl_new(int state, struct mbl_pvt *pvt, char *cid_num
 
 	ast_channel_tech_set(chn, &mbl_tech);
 	ast_format_cap_add(ast_channel_nativeformats(chn), &prefformat);
-	ast_format_copy(&chn->rawreadformat, &prefformat);
-	ast_format_copy(&chn->rawwriteformat, &prefformat);
-	ast_format_copy(&chn->writeformat, &prefformat);
-	ast_format_copy(&chn->readformat, &prefformat);
+	ast_format_copy(ast_channel_rawreadformat(chn), &prefformat);
+	ast_format_copy(ast_channel_rawwriteformat(chn), &prefformat);
+	ast_format_copy(ast_channel_writeformat(chn), &prefformat);
+	ast_format_copy(ast_channel_readformat(chn), &prefformat);
 	ast_channel_tech_pvt_set(chn, pvt);
 
 	if (state == AST_STATE_RING)
diff --git a/addons/chan_ooh323.c b/addons/chan_ooh323.c
index b91fac35da4dcf6175d662df06240edfe8a640a5..ebdbfa17c029cff9d506a456363a30e2f7493d55 100644
--- a/addons/chan_ooh323.c
+++ b/addons/chan_ooh323.c
@@ -390,8 +390,8 @@ static struct ast_channel *ooh323_new(struct ooh323_pvt *i, int state,
 			ast_codec_pref_index(&i->prefs, 0, &tmpfmt);
 
 		ast_format_cap_add(ast_channel_nativeformats(ch), &tmpfmt);
-		ast_format_copy(&ch->rawwriteformat, &tmpfmt);
-		ast_format_copy(&ch->rawreadformat, &tmpfmt);
+		ast_format_copy(ast_channel_rawwriteformat(ch), &tmpfmt);
+		ast_format_copy(ast_channel_rawreadformat(ch), &tmpfmt);
 
 		ast_jb_configure(ch, &global_jbconf);
 
@@ -1177,8 +1177,8 @@ static int ooh323_write(struct ast_channel *ast, struct ast_frame *f)
 							"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
 							ast_getformatname(&f->subclass.format),
 							ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
-							ast_getformatname(&ast->readformat),
-							ast_getformatname(&ast->writeformat));
+							ast_getformatname(ast_channel_readformat(ast)),
+							ast_getformatname(ast_channel_writeformat(ast)));
 
 					ast_set_write_format(ast, &f->subclass.format);
 				} else {
@@ -1512,7 +1512,7 @@ void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txfra
 		}
 		if (gH323Debug)
 	  		ast_verb(0, "Writeformat before update %s/%s\n", 
-			  ast_getformatname(&p->owner->writeformat),
+			  ast_getformatname(ast_channel_writeformat(p->owner)),
 			  ast_getformatname_multiple(formats, sizeof(formats), ast_channel_nativeformats(p->owner)));
 		if (txframes)
 			ast_codec_pref_setsize(&p->prefs, fmt, txframes);
@@ -1527,8 +1527,8 @@ void ooh323_set_write_format(ooCallData *call, struct ast_format *fmt, int txfra
 		}
 
 		ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
-	  	ast_set_write_format(p->owner, &p->owner->writeformat);
-	  	ast_set_read_format(p->owner, &p->owner->readformat);
+	  	ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
+	  	ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
 		ast_channel_unlock(p->owner);
    	} else
 		ast_log(LOG_ERROR, "No owner found\n");
@@ -1571,9 +1571,9 @@ void ooh323_set_read_format(ooCallData *call, struct ast_format *fmt)
 
 		if (gH323Debug)
 	  		ast_verb(0, "Readformat before update %s\n", 
-				  ast_getformatname(&p->owner->readformat));
+				  ast_getformatname(ast_channel_readformat(p->owner)));
 		ast_format_cap_set(ast_channel_nativeformats(p->owner), fmt);
-	  	ast_set_read_format(p->owner, &p->owner->readformat);
+	  	ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
 		ast_channel_unlock(p->owner);
    	} else
 		ast_log(LOG_ERROR, "No owner found\n");
@@ -4196,7 +4196,7 @@ static int ooh323_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance
 		return 0;
 	}
 
-	if (ooh323_convertAsteriskCapToH323Cap(&chan->writeformat) < 0) {
+	if (ooh323_convertAsteriskCapToH323Cap(ast_channel_writeformat(chan)) < 0) {
 		ast_log(LOG_WARNING, "Unknown format.\n");
 		return -1;
 	}
@@ -4619,8 +4619,8 @@ struct ast_frame *ooh323_rtp_read(struct ast_channel *ast, struct ooh323_pvt *p)
 		if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(p->owner), &f->subclass.format))) {
 			ast_debug(1, "Oooh, voice format changed to %s\n", ast_getformatname(&f->subclass.format));
 			ast_format_cap_set(ast_channel_nativeformats(p->owner), &f->subclass.format);
-			ast_set_read_format(p->owner, &p->owner->readformat);
-			ast_set_write_format(p->owner, &p->owner->writeformat);
+			ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+			ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
 		}
 		if (((p->dtmfmode & H323_DTMF_INBAND) || (p->faxdetect & FAXDETECT_CNG)) && p->vad &&
 		    (f->subclass.format.id == AST_FORMAT_SLINEAR || f->subclass.format.id == AST_FORMAT_ALAW ||
diff --git a/apps/app_amd.c b/apps/app_amd.c
index 0e0301007cffa9497ce66fab3f77ebd4e24ac6f6..6aefe9ac9f8a73894514963e2db4a411ce8e116b 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -195,7 +195,7 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
 	ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", ast_channel_name(chan),
 		S_COR(chan->caller.ani.number.valid, chan->caller.ani.number.str, "(N/A)"),
 		S_COR(chan->redirecting.from.number.valid, chan->redirecting.from.number.str, "(N/A)"),
-		ast_getformatname(&chan->readformat));
+		ast_getformatname(ast_channel_readformat(chan)));
 
 	/* Lets parse the arguments. */
 	if (!ast_strlen_zero(parse)) {
@@ -244,7 +244,7 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
 				minimumWordLength, betweenWordsSilence, maximumNumberOfWords, silenceThreshold, maximumWordLength);
 
 	/* Set read format to signed linear so we get signed linear frames in */
-	ast_format_copy(&readFormat, &chan->readformat);
+	ast_format_copy(&readFormat, ast_channel_readformat(chan));
 	if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR) < 0 ) {
 		ast_log(LOG_WARNING, "AMD: Channel [%s]. Unable to set to linear mode, giving up\n", ast_channel_name(chan));
 		pbx_builtin_setvar_helper(chan , "AMDSTATUS", "");
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 621f98b2c825023cddac41d10e90f9a8a0fde473..a7afe978048b006a8b9d0e8982040d11e4a82006 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -1123,7 +1123,7 @@ static int chanspy_exec(struct ast_channel *chan, const char *data)
 		ast_clear_flag(&flags, AST_FLAGS_ALL);
 	}
 
-	ast_format_copy(&oldwf, &chan->writeformat);
+	ast_format_copy(&oldwf, ast_channel_writeformat(chan));
 	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
 		return -1;
@@ -1247,7 +1247,7 @@ static int extenspy_exec(struct ast_channel *chan, const char *data)
 		ast_clear_flag(&flags, AST_FLAGS_ALL);
 	}
 
-	oldwf = chan->writeformat;
+	ast_format_copy(&oldwf, ast_channel_writeformat(chan));
 	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
 		return -1;
@@ -1297,7 +1297,7 @@ static int dahdiscan_exec(struct ast_channel *chan, const char *data)
 	ast_set_flag(&flags, OPTION_DTMF_CYCLE);
 	ast_set_flag(&flags, OPTION_DAHDI_SCAN);
 
-	ast_format_copy(&oldwf, &chan->writeformat);
+	ast_format_copy(&oldwf, ast_channel_writeformat(chan));
 	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
 		return -1;
diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index 4e9d5a5e05f67cb5558cf34ec73876b1774b59d0..299864022cb5dec95c60c0f1ee1a473ee13db3b4 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -380,10 +380,10 @@ static struct ast_channel *rec_request(const char *type, struct ast_format_cap *
 	ast_format_set(&fmt, AST_FORMAT_SLINEAR, 0);
 	ast_channel_tech_set(tmp, &record_tech);
 	ast_format_cap_add_all(ast_channel_nativeformats(tmp));
-	ast_format_copy(&tmp->writeformat, &fmt);
-	ast_format_copy(&tmp->rawwriteformat, &fmt);
-	ast_format_copy(&tmp->readformat, &fmt);
-	ast_format_copy(&tmp->rawreadformat, &fmt);
+	ast_format_copy(ast_channel_writeformat(tmp), &fmt);
+	ast_format_copy(ast_channel_rawwriteformat(tmp), &fmt);
+	ast_format_copy(ast_channel_readformat(tmp), &fmt);
+	ast_format_copy(ast_channel_rawreadformat(tmp), &fmt);
 	return tmp;
 }
 
diff --git a/apps/app_dictate.c b/apps/app_dictate.c
index 2158b8c861b5f61329e13dea784d8043d0689381..32ee59475aeef1eb1777acb112fd9fd1cf48b78d 100644
--- a/apps/app_dictate.c
+++ b/apps/app_dictate.c
@@ -126,7 +126,7 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
 	if (args.argc > 1 && args.filename) {
 		filename = args.filename;
 	}
-	ast_format_copy(&oldr, &chan->readformat);
+	ast_format_copy(&oldr, ast_channel_readformat(chan));
 	if ((res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) < 0) {
 		ast_log(LOG_WARNING, "Unable to set to linear mode.\n");
 		return -1;
diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c
index 27e79e1980a63c50dfb66c0f4e18b2e78f746e85..c16318f68cfaaac9b4dda9fa7bbcb5c313f24918 100644
--- a/apps/app_dumpchan.c
+++ b/apps/app_dumpchan.c
@@ -143,10 +143,10 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
 		ast_channel_state(c),
 		ast_channel_rings(c), 
 		ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(c)),
-		ast_getformatname(&c->writeformat),
-		ast_getformatname(&c->readformat),
-		ast_getformatname(&c->rawwriteformat),
-		ast_getformatname(&c->rawreadformat),
+		ast_getformatname(ast_channel_writeformat(c)),
+		ast_getformatname(ast_channel_readformat(c)),
+		ast_getformatname(ast_channel_rawwriteformat(c)),
+		ast_getformatname(ast_channel_rawreadformat(c)),
 		ast_channel_writetrans(c) ? "Yes" : "No",
 		ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
 		ast_channel_readtrans(c) ? "Yes" : "No",
diff --git a/apps/app_fax.c b/apps/app_fax.c
index 2c2960e782784ccbe31b0e22f189587a5e30affd..4d7382b5e484df382ff8705f3a1d58fb8d870518 100644
--- a/apps/app_fax.c
+++ b/apps/app_fax.c
@@ -465,7 +465,7 @@ static int transmit_audio(fax_session *s)
         t30state = &fax.t30_state;
 #endif
 
-	ast_format_copy(&original_read_fmt, &s->chan->readformat);
+	ast_format_copy(&original_read_fmt, ast_channel_readformat(s->chan));
 	if (original_read_fmt.id != AST_FORMAT_SLINEAR) {
 		res = ast_set_read_format_by_id(s->chan, AST_FORMAT_SLINEAR);
 		if (res < 0) {
@@ -474,7 +474,7 @@ static int transmit_audio(fax_session *s)
 		}
 	}
 
-	ast_format_copy(&original_write_fmt, &s->chan->writeformat);
+	ast_format_copy(&original_write_fmt, ast_channel_writeformat(s->chan));
 	if (original_write_fmt.id != AST_FORMAT_SLINEAR) {
 		res = ast_set_write_format_by_id(s->chan, AST_FORMAT_SLINEAR);
 		if (res < 0) {
diff --git a/apps/app_festival.c b/apps/app_festival.c
index cd1cfa05182a0a0972cec1787dbd7f295ad2991e..fe38bb6fe557892e91aeeed6ff2ae29f7e5ae074 100644
--- a/apps/app_festival.c
+++ b/apps/app_festival.c
@@ -190,7 +190,7 @@ static int send_waveform_to_channel(struct ast_channel *chan, char *waveform, in
 	ast_stopstream(chan);
 	ast_indicate(chan, -1);
 	
-	ast_format_copy(&owriteformat, &chan->writeformat);
+	ast_format_copy(&owriteformat, ast_channel_writeformat(chan));
 	res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
diff --git a/apps/app_ices.c b/apps/app_ices.c
index 13b27fe2580a7a7a769f6192275322b796d2bac2..8a57860b455bbd40b53503357f9b12a6d911c30c 100644
--- a/apps/app_ices.c
+++ b/apps/app_ices.c
@@ -145,7 +145,7 @@ static int ices_exec(struct ast_channel *chan, const char *data)
 		return -1;
 	}
 
-	ast_format_copy(&oreadformat, &chan->readformat);
+	ast_format_copy(&oreadformat, ast_channel_readformat(chan));
 	res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
 	if (res < 0) {
 		close(fds[0]);
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index b6e0c13cb4d0707d753a2a3d783ebe5c6db9467f..5b3fa25bdf0a458ca65803c9f1fe6502a1cc4675 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -3717,7 +3717,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
 						 )) {
 						int idx;
 						for (idx = 0; idx < AST_FRAME_BITS; idx++) {
-							if (ast_format_to_old_bitfield(&chan->rawwriteformat) & (1 << idx)) {
+							if (ast_format_to_old_bitfield(ast_channel_rawwriteformat(chan)) & (1 << idx)) {
 								break;
 							}
 						}
diff --git a/apps/app_mp3.c b/apps/app_mp3.c
index 4c99be72d7b9cbbe996c0237f555672c0a634b52..463a91906f849cf3ebeed1b773655aa07bf88acf 100644
--- a/apps/app_mp3.c
+++ b/apps/app_mp3.c
@@ -168,7 +168,7 @@ static int mp3_exec(struct ast_channel *chan, const char *data)
 	
 	ast_stopstream(chan);
 
-	ast_format_copy(&owriteformat, &chan->writeformat);
+	ast_format_copy(&owriteformat, ast_channel_writeformat(chan));
 	res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
diff --git a/apps/app_nbscat.c b/apps/app_nbscat.c
index 0936534953ced54cae8079ed41dd73d59de991ff..8cf02b369906bc2659ca641ae169f98170629ed4 100644
--- a/apps/app_nbscat.c
+++ b/apps/app_nbscat.c
@@ -132,7 +132,7 @@ static int NBScat_exec(struct ast_channel *chan, const char *data)
 	
 	ast_stopstream(chan);
 
-	ast_format_copy(&owriteformat, &chan->writeformat);
+	ast_format_copy(&owriteformat, ast_channel_writeformat(chan));
 	res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
diff --git a/apps/app_record.c b/apps/app_record.c
index b7c6bfab7cc4e5138907ba0a4bcc9b9db5c3a3ea..3499cb1189f3634e7c20c1019d27e952817c8fd5 100644
--- a/apps/app_record.c
+++ b/apps/app_record.c
@@ -291,7 +291,7 @@ static int record_exec(struct ast_channel *chan, const char *data)
 	/* The end of beep code.  Now the recording starts */
 
 	if (silence > 0) {
-		ast_format_copy(&rfmt, &chan->readformat);
+		ast_format_copy(&rfmt, ast_channel_readformat(chan));
 		res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
 		if (res < 0) {
 			ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c
index 8e6113be89bce33d43af52606116001cf455f5cd..fdf67bb90ec16ef4a99246a80d2409565cce1d07 100644
--- a/apps/app_speech_utils.c
+++ b/apps/app_speech_utils.c
@@ -678,7 +678,7 @@ static int speech_background(struct ast_channel *chan, const char *data)
 	}
 
 	/* Record old read format */
-	ast_format_copy(&oldreadformat, &chan->readformat);
+	ast_format_copy(&oldreadformat, ast_channel_readformat(chan));
 
 	/* Change read format to be signed linear */
 	if (ast_set_read_format(chan, &speech->format))
diff --git a/apps/app_talkdetect.c b/apps/app_talkdetect.c
index 0250f2262ffbabc94685c907d32d9eecc10ba19a..55904d6d2f21fbdf1536327e244574dffe1bbedc 100644
--- a/apps/app_talkdetect.c
+++ b/apps/app_talkdetect.c
@@ -131,7 +131,7 @@ static int background_detect_exec(struct ast_channel *chan, const char *data)
 			}
 		}
 
-		ast_format_copy(&origrformat, &chan->readformat);
+		ast_format_copy(&origrformat, ast_channel_readformat(chan));
 		if ((ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR))) {
 			ast_log(LOG_WARNING, "Unable to set read format to linear!\n");
 			res = -1;
diff --git a/apps/app_test.c b/apps/app_test.c
index bf66824ec08962400b6b7f3ca571b59ff0135a8b..5b7b979e6f87ed1d1d7eb89d06c3de28d12cc8fe 100644
--- a/apps/app_test.c
+++ b/apps/app_test.c
@@ -93,7 +93,7 @@ static int measurenoise(struct ast_channel *chan, int ms, char *who)
 	struct ast_frame *f;
 	struct ast_format rformat;
 
-	ast_format_copy(&rformat, &chan->readformat);
+	ast_format_copy(&rformat, ast_channel_readformat(chan));
 	if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_NOTICE, "Unable to set to linear mode!\n");
 		return -1;
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 3a90b9944b5b8d924e7987921f099be29cf4ac35..2453d01e2b21bb3ab8bf506f7e288253a13af3b4 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -12814,12 +12814,12 @@ AST_TEST_DEFINE(test_voicemail_vmsayname)
 	}
 
 	/* normally this is done in the channel driver */
-	ast_format_set(&test_channel1->writeformat, AST_FORMAT_GSM, 0);
+	ast_format_set(ast_channel_writeformat(test_channel1), AST_FORMAT_GSM, 0);
 	nativeformats = ast_channel_nativeformats(test_channel1);
-	ast_format_cap_add(nativeformats, &test_channel1->writeformat);
-	ast_format_set(&test_channel1->rawwriteformat, AST_FORMAT_GSM, 0);
-	ast_format_set(&test_channel1->readformat, AST_FORMAT_GSM, 0);
-	ast_format_set(&test_channel1->rawreadformat, AST_FORMAT_GSM, 0);
+	ast_format_cap_add(nativeformats, ast_channel_writeformat(test_channel1));
+	ast_format_set(ast_channel_rawwriteformat(test_channel1), AST_FORMAT_GSM, 0);
+	ast_format_set(ast_channel_readformat(test_channel1), AST_FORMAT_GSM, 0);
+	ast_format_set(ast_channel_rawreadformat(test_channel1), AST_FORMAT_GSM, 0);
 	ast_channel_tech_set(test_channel1, &fake_tech);
 
 	ast_test_status_update(test, "Test playing of extension when greeting is not available...\n");
diff --git a/apps/app_waitforsilence.c b/apps/app_waitforsilence.c
index 1964376aa2fb0c8417ce69561e0c366748bf2635..f79247274f678d00166f3d085ebf83282f55a677 100644
--- a/apps/app_waitforsilence.c
+++ b/apps/app_waitforsilence.c
@@ -138,7 +138,7 @@ static int do_waiting(struct ast_channel *chan, int timereqd, time_t waitstart,
 	int (*ast_dsp_func)(struct ast_dsp*, struct ast_frame*, int*) =
 				wait_for_silence ? ast_dsp_silence : ast_dsp_noise;
 
-	ast_format_copy(&rfmt, &chan->readformat); /* Set to linear mode */
+	ast_format_copy(&rfmt, ast_channel_readformat(chan)); /* Set to linear mode */
 	if ((res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) < 0) {
 		ast_log(LOG_WARNING, "Unable to set channel to linear mode, giving up\n");
 		return -1;
diff --git a/bridges/bridge_multiplexed.c b/bridges/bridge_multiplexed.c
index 89bf5842fc6fa3a2dc194e32e24f6cc75b50aabf..8d18ab548f0e0f8bf593fd93a60511cdec6e6788 100644
--- a/bridges/bridge_multiplexed.c
+++ b/bridges/bridge_multiplexed.c
@@ -327,8 +327,8 @@ static int multiplexed_bridge_join(struct ast_bridge *bridge, struct ast_bridge_
 		return 0;
 	}
 
-	if ((ast_format_cmp(&c0->writeformat, &c1->readformat) == AST_FORMAT_CMP_EQUAL) &&
-		(ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_EQUAL) &&
+	if ((ast_format_cmp(ast_channel_writeformat(c0), ast_channel_readformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
+		(ast_format_cmp(ast_channel_readformat(c0), ast_channel_writeformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
 		(ast_format_cap_identical(ast_channel_nativeformats(c0), ast_channel_nativeformats(c1)))) {
 		return 0;
 	}
diff --git a/bridges/bridge_simple.c b/bridges/bridge_simple.c
index 19bcd295ab8dd24c77ae34dde6b988a7779d67bf..69e41140d70de7105b3ad92d3161bb15026086ec 100644
--- a/bridges/bridge_simple.c
+++ b/bridges/bridge_simple.c
@@ -55,8 +55,8 @@ static int simple_bridge_join(struct ast_bridge *bridge, struct ast_bridge_chann
 	}
 
 	/* See if we need to make these compatible */
-	if ((ast_format_cmp(&c0->writeformat, &c1->readformat) == AST_FORMAT_CMP_EQUAL) &&
-		(ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_EQUAL) &&
+	if ((ast_format_cmp(ast_channel_writeformat(c0), ast_channel_readformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
+		(ast_format_cmp(ast_channel_readformat(c0), ast_channel_writeformat(c1)) == AST_FORMAT_CMP_EQUAL) &&
 		(ast_format_cap_identical(ast_channel_nativeformats(c0), ast_channel_nativeformats(c1)))) {
 		return 0;
 	}
diff --git a/bridges/bridge_softmix.c b/bridges/bridge_softmix.c
index 7632f36ee693aed3075b56dc967259e27f9d76dc..52e5551170f7e8669422cb57457ae90c98991bcc 100644
--- a/bridges/bridge_softmix.c
+++ b/bridges/bridge_softmix.c
@@ -336,7 +336,7 @@ static int softmix_bridge_destroy(struct ast_bridge *bridge)
 static void set_softmix_bridge_data(int rate, int interval, struct ast_bridge_channel *bridge_channel, int reset)
 {
 	struct softmix_channel *sc = bridge_channel->bridge_pvt;
-	unsigned int channel_read_rate = ast_format_rate(&bridge_channel->chan->rawreadformat);
+	unsigned int channel_read_rate = ast_format_rate(ast_channel_rawreadformat(bridge_channel->chan));
 
 	ast_mutex_lock(&sc->lock);
 	if (reset) {
@@ -614,8 +614,8 @@ static void gather_softmix_stats(struct softmix_stats *stats,
 	int channel_native_rate;
 	int i;
 	/* Gather stats about channel sample rates. */
-	channel_native_rate = MAX(ast_format_rate(&bridge_channel->chan->rawwriteformat),
-		ast_format_rate(&bridge_channel->chan->rawreadformat));
+	channel_native_rate = MAX(ast_format_rate(ast_channel_rawwriteformat(bridge_channel->chan)),
+		ast_format_rate(ast_channel_rawreadformat(bridge_channel->chan)));
 
 	if (channel_native_rate > stats->highest_supported_rate) {
 		stats->highest_supported_rate = channel_native_rate;
@@ -859,7 +859,7 @@ static int softmix_bridge_thread(struct ast_bridge *bridge)
 			memcpy(sc->final_buf, buf, softmix_datalen);
 
 			/* process the softmix channel's new write audio */
-			softmix_process_write_audio(&trans_helper, &bridge_channel->chan->rawwriteformat, sc);
+			softmix_process_write_audio(&trans_helper, ast_channel_rawwriteformat(bridge_channel->chan), sc);
 
 			/* The frame is now ready for use... */
 			sc->have_frame = 1;
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index b2744af0008a6a70e7b9c1597632a33644912688..9eb0b68f913335676eeb88f93e6061499f904f73 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -303,14 +303,14 @@ static AST_LIST_HEAD_STATIC(agents, agent_pvt);	/*!< Holds the list of agents (l
 			ast_debug(1, "Native formats changing from '%s' to '%s'\n", ast_getformatname_multiple(tmp1, sizeof(tmp1), ast_channel_nativeformats(ast)), ast_getformatname_multiple(tmp2, sizeof(tmp2), ast_channel_nativeformats(p->chan))); \
 			/* Native formats changed, reset things */ \
 			ast_format_cap_copy(ast_channel_nativeformats(ast), ast_channel_nativeformats(p->chan)); \
-			ast_debug(1, "Resetting read to '%s' and write to '%s'\n", ast_getformatname(&ast->readformat), ast_getformatname(&ast->writeformat));\
-			ast_set_read_format(ast, &ast->readformat); \
-			ast_set_write_format(ast, &ast->writeformat); \
+			ast_debug(1, "Resetting read to '%s' and write to '%s'\n", ast_getformatname(ast_channel_readformat(ast)), ast_getformatname(ast_channel_writeformat(ast)));\
+			ast_set_read_format(ast, ast_channel_readformat(ast)); \
+			ast_set_write_format(ast, ast_channel_writeformat(ast)); \
 		} \
-		if ((ast_format_cmp(&p->chan->readformat, &ast->rawreadformat) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan))  \
-			ast_set_read_format(p->chan, &ast->rawreadformat); \
-		if ((ast_format_cmp(&p->chan->writeformat, &ast->rawwriteformat) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan)) \
-			ast_set_write_format(p->chan, &ast->rawwriteformat); \
+		if ((ast_format_cmp(ast_channel_readformat(p->chan), ast_channel_rawreadformat(ast)) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan))  \
+			ast_set_read_format(p->chan, ast_channel_rawreadformat(ast)); \
+		if ((ast_format_cmp(ast_channel_writeformat(p->chan), ast_channel_rawwriteformat(ast)) != AST_FORMAT_CMP_EQUAL) && !ast_channel_generator(p->chan)) \
+			ast_set_write_format(p->chan, ast_channel_rawwriteformat(ast)); \
 	} \
 } while(0)
 
@@ -742,7 +742,7 @@ static int agent_write(struct ast_channel *ast, struct ast_frame *f)
 	else {
 		if ((f->frametype != AST_FRAME_VOICE) ||
 		    (f->frametype != AST_FRAME_VIDEO) ||
-		    (ast_format_cmp(&f->subclass.format, &p->chan->writeformat) != AST_FORMAT_CMP_NOT_EQUAL)) {
+		    (ast_format_cmp(&f->subclass.format, ast_channel_writeformat(p->chan)) != AST_FORMAT_CMP_NOT_EQUAL)) {
 			res = ast_write(p->chan, f);
 		} else {
 			ast_debug(1, "Dropping one incompatible %s frame on '%s' to '%s'\n", 
@@ -1114,20 +1114,20 @@ static struct ast_channel *agent_new(struct agent_pvt *p, int state, const char
 	ast_channel_tech_set(tmp, &agent_tech);
 	if (p->chan) {
 		ast_format_cap_copy(ast_channel_nativeformats(tmp), ast_channel_nativeformats(p->chan));
-		ast_format_copy(&tmp->writeformat, &p->chan->writeformat);
-		ast_format_copy(&tmp->rawwriteformat, &p->chan->writeformat);
-		ast_format_copy(&tmp->readformat, &p->chan->readformat);
-		ast_format_copy(&tmp->rawreadformat, &p->chan->readformat);
+		ast_format_copy(ast_channel_writeformat(tmp), ast_channel_writeformat(p->chan));
+		ast_format_copy(ast_channel_rawwriteformat(tmp), ast_channel_writeformat(p->chan));
+		ast_format_copy(ast_channel_readformat(tmp), ast_channel_readformat(p->chan));
+		ast_format_copy(ast_channel_rawreadformat(tmp), ast_channel_readformat(p->chan));
 		ast_channel_language_set(tmp, ast_channel_language(p->chan));
 		ast_channel_context_set(tmp, ast_channel_context(p->chan));
 		ast_channel_exten_set(tmp, ast_channel_exten(p->chan));
 		/* XXX Is this really all we copy form the originating channel?? */
 	} else {
-		ast_format_set(&tmp->writeformat, AST_FORMAT_SLINEAR, 0);
-		ast_format_set(&tmp->rawwriteformat, AST_FORMAT_SLINEAR, 0);
-		ast_format_set(&tmp->readformat, AST_FORMAT_SLINEAR, 0);
-		ast_format_set(&tmp->rawreadformat, AST_FORMAT_SLINEAR, 0);
-		ast_format_cap_add(ast_channel_nativeformats(tmp), &tmp->writeformat);
+		ast_format_set(ast_channel_writeformat(tmp), AST_FORMAT_SLINEAR, 0);
+		ast_format_set(ast_channel_rawwriteformat(tmp), AST_FORMAT_SLINEAR, 0);
+		ast_format_set(ast_channel_readformat(tmp), AST_FORMAT_SLINEAR, 0);
+		ast_format_set(ast_channel_rawreadformat(tmp), AST_FORMAT_SLINEAR, 0);
+		ast_format_cap_add(ast_channel_nativeformats(tmp), ast_channel_writeformat(tmp));
 	}
 	/* Safe, agentlock already held */
 	ast_channel_tech_pvt_set(tmp, p);
@@ -2127,7 +2127,7 @@ static int login_exec(struct ast_channel *chan, const char *data)
 							snprintf(ast_channel_cdr(chan)->channel, sizeof(ast_channel_cdr(chan)->channel), "Agent/%s", p->agent);
 						ast_queue_log("NONE", ast_channel_uniqueid(chan), agent, "AGENTLOGIN", "%s", ast_channel_name(chan));
 						ast_verb(2, "Agent '%s' logged in (format %s/%s)\n", p->agent,
-								    ast_getformatname(&chan->readformat), ast_getformatname(&chan->writeformat));
+								    ast_getformatname(ast_channel_readformat(chan)), ast_getformatname(ast_channel_writeformat(chan)));
 						/* Login this channel and wait for it to go away */
 						p->chan = chan;
 						if (p->ackcall) {
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 4424ef18db20898a9c832d2107b35ef78aedeb41..0ebfd3f2209add1de2008d69a6dfe6b531c73169 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -572,9 +572,9 @@ static struct ast_channel *alsa_new(struct chan_alsa_pvt *p, int state, const ch
 
 	ast_channel_tech_set(tmp, &alsa_tech);
 	ast_channel_set_fd(tmp, 0, readdev);
-	ast_format_set(&tmp->readformat, AST_FORMAT_SLINEAR, 0);
-	ast_format_set(&tmp->writeformat, AST_FORMAT_SLINEAR, 0);
-	ast_format_cap_add(ast_channel_nativeformats(tmp), &tmp->writeformat);
+	ast_format_set(ast_channel_readformat(tmp), AST_FORMAT_SLINEAR, 0);
+	ast_format_set(ast_channel_writeformat(tmp), AST_FORMAT_SLINEAR, 0);
+	ast_format_cap_add(ast_channel_nativeformats(tmp), ast_channel_writeformat(tmp));
 
 	ast_channel_tech_pvt_set(tmp, p);
 	if (!ast_strlen_zero(p->context))
diff --git a/channels/chan_bridge.c b/channels/chan_bridge.c
index 67af0737e630ad9d4b4e0d2950d1867b69d9212b..3ec157601c78cade049932d593004d803e95389c 100644
--- a/channels/chan_bridge.c
+++ b/channels/chan_bridge.c
@@ -188,14 +188,14 @@ static struct ast_channel *bridge_request(const char *type, struct ast_format_ca
 
 	ast_format_cap_add(ast_channel_nativeformats(p->input), &slin);
 	ast_format_cap_add(ast_channel_nativeformats(p->output), &slin);
-	ast_format_copy(&p->input->readformat, &slin);
-	ast_format_copy(&p->output->readformat, &slin);
-	ast_format_copy(&p->input->rawreadformat, &slin);
-	ast_format_copy(&p->output->rawreadformat, &slin);
-	ast_format_copy(&p->input->writeformat, &slin);
-	ast_format_copy(&p->output->writeformat, &slin);
-	ast_format_copy(&p->input->rawwriteformat, &slin);
-	ast_format_copy(&p->output->rawwriteformat, &slin);
+	ast_format_copy(ast_channel_readformat(p->input), &slin);
+	ast_format_copy(ast_channel_readformat(p->output), &slin);
+	ast_format_copy(ast_channel_rawreadformat(p->input), &slin);
+	ast_format_copy(ast_channel_rawreadformat(p->output), &slin);
+	ast_format_copy(ast_channel_writeformat(p->input), &slin);
+	ast_format_copy(ast_channel_writeformat(p->output), &slin);
+	ast_format_copy(ast_channel_rawwriteformat(p->input), &slin);
+	ast_format_copy(ast_channel_rawwriteformat(p->output), &slin);
 
 	ast_answer(p->output);
 	ast_answer(p->input);
diff --git a/channels/chan_console.c b/channels/chan_console.c
index a47f898260309c4ac7b4f59e467834ed744fb351..02fca590cb56e008cb4ee6eb6a19ff059c021178 100644
--- a/channels/chan_console.c
+++ b/channels/chan_console.c
@@ -420,9 +420,9 @@ static struct ast_channel *console_new(struct console_pvt *pvt, const char *ext,
 	}
 
 	ast_channel_tech_set(chan, &console_tech);
-	ast_format_set(&chan->readformat, AST_FORMAT_SLINEAR16, 0);
-	ast_format_set(&chan->writeformat, AST_FORMAT_SLINEAR16, 0);
-	ast_format_cap_add(ast_channel_nativeformats(chan), &chan->readformat);
+	ast_format_set(ast_channel_readformat(chan), AST_FORMAT_SLINEAR16, 0);
+	ast_format_set(ast_channel_writeformat(chan), AST_FORMAT_SLINEAR16, 0);
+	ast_format_cap_add(ast_channel_nativeformats(chan), ast_channel_readformat(chan));
 	ast_channel_tech_pvt_set(chan, ref_pvt(pvt));
 
 	pvt->owner = chan;
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index 59e1ff09dc64109f7e9c9ac17ddc6fcda2efe696..24674218816654bcc2f0845f61e059d2076a5a1b 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -9116,15 +9116,15 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
 		return f;
 	}
 
-	if (ast->rawreadformat.id == AST_FORMAT_SLINEAR) {
+	if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_SLINEAR) {
 		if (!p->subs[idx].linear) {
 			p->subs[idx].linear = 1;
 			res = dahdi_setlinear(p->subs[idx].dfd, p->subs[idx].linear);
 			if (res)
 				ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to linear mode.\n", p->channel, idx);
 		}
-	} else if ((ast->rawreadformat.id == AST_FORMAT_ULAW) ||
-		(ast->rawreadformat.id == AST_FORMAT_ALAW)) {
+	} else if ((ast_channel_rawreadformat(ast)->id == AST_FORMAT_ULAW) ||
+		(ast_channel_rawreadformat(ast)->id == AST_FORMAT_ALAW)) {
 		if (p->subs[idx].linear) {
 			p->subs[idx].linear = 0;
 			res = dahdi_setlinear(p->subs[idx].dfd, p->subs[idx].linear);
@@ -9132,7 +9132,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
 				ast_log(LOG_WARNING, "Unable to set channel %d (index %d) to companded mode.\n", p->channel, idx);
 		}
 	} else {
-		ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(&ast->rawreadformat));
+		ast_log(LOG_WARNING, "Don't know how to read frames in format %s\n", ast_getformatname(ast_channel_rawreadformat(ast)));
 		ast_mutex_unlock(&p->lock);
 		return NULL;
 	}
@@ -9224,7 +9224,7 @@ static struct ast_frame *dahdi_read(struct ast_channel *ast)
 	}
 
 	p->subs[idx].f.frametype = AST_FRAME_VOICE;
-	ast_format_copy(&p->subs[idx].f.subclass.format, &ast->rawreadformat);
+	ast_format_copy(&p->subs[idx].f.subclass.format, ast_channel_rawreadformat(ast));
 	p->subs[idx].f.samples = READ_SIZE;
 	p->subs[idx].f.mallocd = 0;
 	p->subs[idx].f.offset = AST_FRIENDLY_OFFSET;
@@ -9675,10 +9675,10 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
 	ast_channel_set_fd(tmp, 0, i->subs[idx].dfd);
 	ast_format_cap_add(ast_channel_nativeformats(tmp), &deflaw);
 	/* Start out assuming ulaw since it's smaller :) */
-	ast_format_copy(&tmp->rawreadformat, &deflaw);
-	ast_format_copy(&tmp->readformat, &deflaw);
-	ast_format_copy(&tmp->rawwriteformat, &deflaw);
-	ast_format_copy(&tmp->writeformat, &deflaw);
+	ast_format_copy(ast_channel_rawreadformat(tmp), &deflaw);
+	ast_format_copy(ast_channel_readformat(tmp), &deflaw);
+	ast_format_copy(ast_channel_rawwriteformat(tmp), &deflaw);
+	ast_format_copy(ast_channel_writeformat(tmp), &deflaw);
 	i->subs[idx].linear = 0;
 	dahdi_setlinear(i->subs[idx].dfd, i->subs[idx].linear);
 	features = 0;
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index 3b5354caecf20f11537c5503596eb07e2e61e19d..8db2369d20d9cede1d1a863bc52ff8c7932d4352 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -1170,10 +1170,10 @@ static struct ast_channel *gtalk_new(struct gtalk *client, struct gtalk_pvt *i,
 	ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
 
 	ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
-	ast_format_copy(&tmp->writeformat, &tmpfmt);
-	ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
-	ast_format_copy(&tmp->readformat, &tmpfmt);
-	ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+	ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
 	ast_channel_tech_pvt_set(tmp, i);
 
 	tmp->callgroup = client->callgroup;
@@ -1628,8 +1628,8 @@ static struct ast_frame *gtalk_rtp_read(struct ast_channel *ast, struct gtalk_pv
 				ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
 				ast_format_cap_remove_bytype(ast_channel_nativeformats(p->owner), AST_FORMAT_TYPE_AUDIO);
 				ast_format_cap_add(ast_channel_nativeformats(p->owner), &f->subclass.format);
-				ast_set_read_format(p->owner, &p->owner->readformat);
-				ast_set_write_format(p->owner, &p->owner->writeformat);
+				ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+				ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
 			}
 			/* if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
 				f = ast_dsp_process(p->owner, p->vad, f);
@@ -1666,8 +1666,8 @@ static int gtalk_write(struct ast_channel *ast, struct ast_frame *frame)
 					"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
 					ast_getformatname(&frame->subclass.format),
 					ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
-					ast_getformatname(&ast->readformat),
-					ast_getformatname(&ast->writeformat));
+					ast_getformatname(ast_channel_readformat(ast)),
+					ast_getformatname(ast_channel_writeformat(ast)));
 			return 0;
 		}
 		if (p) {
@@ -1992,8 +1992,8 @@ static char *gtalk_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cl
 					ast_channel_name(chan),
 					jid,
 					resource,
-					ast_getformatname(&chan->readformat),
-					ast_getformatname(&chan->writeformat)
+					ast_getformatname(ast_channel_readformat(chan)),
+					ast_getformatname(ast_channel_writeformat(chan))
 					);
 			else
 				ast_log(LOG_WARNING, "No available channel\n");
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 7a0d8265de1b94a2e2f03c26aa7a70db37df9d68..fba55dcf284db010dccfe8bc7c2413b7e20f18bc 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -5756,10 +5756,10 @@ static struct ast_channel *ast_iax2_new(int callno, int state, iax2_format capab
 	ast_format_cap_from_old_bitfield(ast_channel_nativeformats(tmp), capability);
 	ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
 
-	ast_format_copy(&tmp->readformat, &tmpfmt);
-	ast_format_copy(&tmp->rawreadformat, &tmpfmt);
-	ast_format_copy(&tmp->writeformat, &tmpfmt);
-	ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
+	ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
 
 	ast_channel_tech_pvt_set(tmp, CALLNO_TO_PTR(i->callno));
 
@@ -9353,8 +9353,8 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2, const
 	}
 
 	/* Make formats okay */
-	chan1m->readformat = chan1->readformat;
-	chan1m->writeformat = chan1->writeformat;
+	ast_format_copy(ast_channel_readformat(chan1m), ast_channel_readformat(chan1));
+	ast_format_copy(ast_channel_writeformat(chan1m), ast_channel_writeformat(chan1));
 
 	/* Prepare for taking over the channel */
 	if (ast_channel_masquerade(chan1m, chan1)) {
@@ -9377,8 +9377,8 @@ static int iax_park(struct ast_channel *chan1, struct ast_channel *chan2, const
 	   back the announcement */
 
 	/* Make formats okay */
-	chan2m->readformat = chan2->readformat;
-	chan2m->writeformat = chan2->writeformat;
+	ast_format_copy(ast_channel_readformat(chan2m), ast_channel_readformat(chan2));
+	ast_format_copy(ast_channel_writeformat(chan2m), ast_channel_writeformat(chan2));
 	ast_channel_parkinglot_set(chan2m, ast_channel_parkinglot(chan2));
 
 	/* Prepare for taking over the channel */
@@ -10367,8 +10367,8 @@ static int socket_process(struct iax2_thread *thread)
 								struct ast_format_cap *native = ast_channel_nativeformats(iaxs[fr->callno]->owner);
 								if (orignative) {
 									ast_format_cap_set(native, &f.subclass.format);
-									if (iaxs[fr->callno]->owner->readformat.id) {
-										ast_set_read_format(iaxs[fr->callno]->owner, &iaxs[fr->callno]->owner->readformat);
+									if (ast_channel_readformat(iaxs[fr->callno]->owner)->id) {
+										ast_set_read_format(iaxs[fr->callno]->owner, ast_channel_readformat(iaxs[fr->callno]->owner));
 									}
 									ast_format_cap_copy(native, orignative);
 									ast_channel_unlock(iaxs[fr->callno]->owner);
@@ -10873,10 +10873,10 @@ static int socket_process(struct iax2_thread *thread)
 						ast_verb(3, "Format for call is %s\n", ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(iaxs[fr->callno]->owner)));
 
 						/* Setup read/write formats properly. */
-						if (iaxs[fr->callno]->owner->writeformat.id)
-							ast_set_write_format(iaxs[fr->callno]->owner, &iaxs[fr->callno]->owner->writeformat);
-						if (iaxs[fr->callno]->owner->readformat.id)
-							ast_set_read_format(iaxs[fr->callno]->owner, &iaxs[fr->callno]->owner->readformat);
+						if (ast_channel_writeformat(iaxs[fr->callno]->owner)->id)
+							ast_set_write_format(iaxs[fr->callno]->owner, ast_channel_writeformat(iaxs[fr->callno]->owner));
+						if (ast_channel_readformat(iaxs[fr->callno]->owner)->id)
+							ast_set_read_format(iaxs[fr->callno]->owner, ast_channel_readformat(iaxs[fr->callno]->owner));
 						ast_channel_unlock(iaxs[fr->callno]->owner);
 					}
 				}
@@ -12182,8 +12182,8 @@ static struct ast_channel *iax2_request(const char *type, struct ast_format_cap
 			}
 			ast_format_cap_set(ast_channel_nativeformats(c), &best_fmt_native);
 		}
-		ast_best_codec(ast_channel_nativeformats(c), &c->readformat);
-		ast_format_copy(&c->writeformat, &c->readformat);
+		ast_best_codec(ast_channel_nativeformats(c), ast_channel_readformat(c));
+		ast_format_copy(ast_channel_writeformat(c), ast_channel_readformat(c));
 	}
 
 	return c;
diff --git a/channels/chan_jingle.c b/channels/chan_jingle.c
index a683a41607d1f5a2ac23ce8e932c217c5af69bf2..7156e94432a18b87aea464ab4dda6f37c7bce750 100644
--- a/channels/chan_jingle.c
+++ b/channels/chan_jingle.c
@@ -882,10 +882,10 @@ static struct ast_channel *jingle_new(struct jingle *client, struct jingle_pvt *
 
 
 	ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
-	ast_format_copy(&tmp->writeformat, &tmpfmt);
-	ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
-	ast_format_copy(&tmp->readformat, &tmpfmt);
-	ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+	ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
 	ast_channel_tech_pvt_set(tmp, i);
 
 	tmp->callgroup = client->callgroup;
@@ -1233,8 +1233,8 @@ static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_
 				ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
 				ast_format_cap_remove_bytype(ast_channel_nativeformats(p->owner), AST_FORMAT_TYPE_AUDIO);
 				ast_format_cap_add(ast_channel_nativeformats(p->owner), &f->subclass.format);
-				ast_set_read_format(p->owner, &p->owner->readformat);
-				ast_set_write_format(p->owner, &p->owner->writeformat);
+				ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+				ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
 			}
 /*			if ((ast_test_flag(p, SIP_DTMF) == SIP_DTMF_INBAND) && p->vad) {
 				f = ast_dsp_process(p->owner, p->vad, f);
@@ -1271,8 +1271,8 @@ static int jingle_write(struct ast_channel *ast, struct ast_frame *frame)
 					"Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
 					ast_getformatname(&frame->subclass.format),
 					ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
-					ast_getformatname(&ast->readformat),
-					ast_getformatname(&ast->writeformat));
+					ast_getformatname(ast_channel_readformat(ast)),
+					ast_getformatname(ast_channel_writeformat(ast)));
 			return 0;
 		}
 		if (p) {
@@ -1635,8 +1635,8 @@ static char *jingle_show_channels(struct ast_cli_entry *e, int cmd, struct ast_c
 					ast_channel_name(chan),
 					jid,
 					resource,
-					ast_getformatname(&chan->readformat),
-					ast_getformatname(&chan->writeformat)
+					ast_getformatname(ast_channel_readformat(chan)),
+					ast_getformatname(ast_channel_writeformat(chan))
 					);
 			else 
 				ast_log(LOG_WARNING, "No available channel\n");
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 6123e5484c1d9ef5aabe5e579ac7ce77e6795c6e..550625656fdb8625a206ae369b6d4881692005fd 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -1157,14 +1157,14 @@ static struct ast_channel *local_new(struct local_pvt *p, int state, const char
 
 	/* Determine our read/write format and set it on each channel */
 	ast_best_codec(p->reqcap, &fmt);
-	ast_format_copy(&tmp->writeformat, &fmt);
-	ast_format_copy(&tmp2->writeformat, &fmt);
-	ast_format_copy(&tmp->rawwriteformat, &fmt);
-	ast_format_copy(&tmp2->rawwriteformat, &fmt);
-	ast_format_copy(&tmp->readformat, &fmt);
-	ast_format_copy(&tmp2->readformat, &fmt);
-	ast_format_copy(&tmp->rawreadformat, &fmt);
-	ast_format_copy(&tmp2->rawreadformat, &fmt);
+	ast_format_copy(ast_channel_writeformat(tmp), &fmt);
+	ast_format_copy(ast_channel_writeformat(tmp2), &fmt);
+	ast_format_copy(ast_channel_rawwriteformat(tmp), &fmt);
+	ast_format_copy(ast_channel_rawwriteformat(tmp2), &fmt);
+	ast_format_copy(ast_channel_readformat(tmp), &fmt);
+	ast_format_copy(ast_channel_readformat(tmp2), &fmt);
+	ast_format_copy(ast_channel_rawreadformat(tmp), &fmt);
+	ast_format_copy(ast_channel_rawreadformat(tmp2), &fmt);
 
 	ast_channel_tech_pvt_set(tmp, p);
 	ast_channel_tech_pvt_set(tmp2, p);
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c
index b73ccd24c26baa3f23d321b96ac1f6e6376ad3f6..96c22d1555aa4d501d1abcf5e9c076fa0cce7770 100644
--- a/channels/chan_mgcp.c
+++ b/channels/chan_mgcp.c
@@ -1212,8 +1212,8 @@ static struct ast_frame *mgcp_rtp_read(struct mgcp_subchannel *sub)
 			if (!ast_format_cap_iscompatible(ast_channel_nativeformats(sub->owner), &f->subclass.format)) {
 				ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
 				ast_format_cap_set(ast_channel_nativeformats(sub->owner), &f->subclass.format);
-				ast_set_read_format(sub->owner, &sub->owner->readformat);
-				ast_set_write_format(sub->owner, &sub->owner->writeformat);
+				ast_set_read_format(sub->owner, ast_channel_readformat(sub->owner));
+				ast_set_write_format(sub->owner, ast_channel_writeformat(sub->owner));
 			}
 			/* Courtesy fearnor aka alex@pilosoft.com */
 			if ((sub->parent->dtmfmode & MGCP_DTMF_INBAND) && (sub->parent->dsp)) {
@@ -1256,8 +1256,8 @@ static int mgcp_write(struct ast_channel *ast, struct ast_frame *frame)
 			ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
 				ast_getformatname(&frame->subclass.format),
 				ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
-				ast_getformatname(&ast->readformat),
-				ast_getformatname(&ast->writeformat));
+				ast_getformatname(ast_channel_readformat(ast)),
+				ast_getformatname(ast_channel_writeformat(ast)));
 			/* return -1; */
 		}
 	}
@@ -1518,10 +1518,10 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state, cons
 			ast_channel_rings_set(tmp, 1);
 
 		ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
-		ast_format_copy(&tmp->writeformat, &tmpfmt);
-		ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
-		ast_format_copy(&tmp->readformat, &tmpfmt);
-		ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+		ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
 		ast_channel_tech_pvt_set(tmp, sub);
 		if (!ast_strlen_zero(i->language))
 			ast_channel_language_set(tmp, i->language);
diff --git a/channels/chan_misdn.c b/channels/chan_misdn.c
index d760a1ed0683b6ef151b883d7f072bb448b7edfc..c7ca07b9912ab9620b2ad40df4421ac7e7b10190 100644
--- a/channels/chan_misdn.c
+++ b/channels/chan_misdn.c
@@ -8137,10 +8137,10 @@ static struct ast_channel *misdn_new(struct chan_list *chlist, int state,  char
 
 		ast_best_codec(cap, &tmpfmt);
 		ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
-		ast_format_copy(&tmp->writeformat, &tmpfmt);
-		ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
-		ast_format_copy(&tmp->readformat, &tmpfmt);
-		ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+		ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
 
 		/* Link the channel and private together */
 		chan_list_ref(chlist, "Give a reference to ast_channel");
diff --git a/channels/chan_multicast_rtp.c b/channels/chan_multicast_rtp.c
index 6ebacaa840019baebd7f91a6c693916a01fdc6f0..dfa0680182c50f86e46b06641755b69f3d9d72fe 100644
--- a/channels/chan_multicast_rtp.c
+++ b/channels/chan_multicast_rtp.c
@@ -159,10 +159,10 @@ static struct ast_channel *multicast_rtp_request(const char *type, struct ast_fo
 	ast_channel_tech_set(chan, &multicast_rtp_tech);
 
 	ast_format_cap_add(ast_channel_nativeformats(chan), &fmt);
-	ast_format_copy(&chan->writeformat, &fmt);
-	ast_format_copy(&chan->rawwriteformat, &fmt);
-	ast_format_copy(&chan->readformat, &fmt);
-	ast_format_copy(&chan->rawreadformat, &fmt);
+	ast_format_copy(ast_channel_writeformat(chan), &fmt);
+	ast_format_copy(ast_channel_rawwriteformat(chan), &fmt);
+	ast_format_copy(ast_channel_readformat(chan), &fmt);
+	ast_format_copy(ast_channel_rawreadformat(chan), &fmt);
 
 	ast_channel_tech_pvt_set(chan, instance);
 
diff --git a/channels/chan_nbs.c b/channels/chan_nbs.c
index 882e165f8f91cfa9eb2f9e717e3eaa122ed99488..e6384872ee1e48440d8f164a79572355ab117941 100644
--- a/channels/chan_nbs.c
+++ b/channels/chan_nbs.c
@@ -227,10 +227,10 @@ static struct ast_channel *nbs_new(struct nbs_pvt *i, int state, const char *lin
 		ast_channel_set_fd(tmp, 0, nbs_fd(i->nbs));
 
 		ast_format_cap_add(ast_channel_nativeformats(tmp), &prefformat);
-		ast_format_copy(&tmp->rawreadformat, &prefformat);
-		ast_format_copy(&tmp->rawwriteformat, &prefformat);
-		ast_format_copy(&tmp->writeformat, &prefformat);
-		ast_format_copy(&tmp->readformat, &prefformat);
+		ast_format_copy(ast_channel_rawreadformat(tmp), &prefformat);
+		ast_format_copy(ast_channel_rawwriteformat(tmp), &prefformat);
+		ast_format_copy(ast_channel_writeformat(tmp), &prefformat);
+		ast_format_copy(ast_channel_readformat(tmp), &prefformat);
 		if (state == AST_STATE_RING)
 			ast_channel_rings_set(tmp, 1);
 		ast_channel_tech_pvt_set(tmp, i);
diff --git a/channels/chan_oss.c b/channels/chan_oss.c
index 2d7cda82ad63b446ae430f197de5637511e0e82c..47a9958423724f779b6331ce2342bf8938d9695c 100644
--- a/channels/chan_oss.c
+++ b/channels/chan_oss.c
@@ -797,9 +797,9 @@ static struct ast_channel *oss_new(struct chan_oss_pvt *o, char *ext, char *ctx,
 		setformat(o, O_RDWR);
 	ast_channel_set_fd(c, 0, o->sounddev); /* -1 if device closed, override later */
 
-	ast_format_set(&c->readformat, AST_FORMAT_SLINEAR, 0);
-	ast_format_set(&c->writeformat, AST_FORMAT_SLINEAR, 0);
-	ast_format_cap_add(ast_channel_nativeformats(c), &c->readformat);
+	ast_format_set(ast_channel_readformat(c), AST_FORMAT_SLINEAR, 0);
+	ast_format_set(ast_channel_writeformat(c), AST_FORMAT_SLINEAR, 0);
+	ast_format_cap_add(ast_channel_nativeformats(c), ast_channel_readformat(c));
 
 	/* if the console makes the call, add video to the offer */
 	/* if (state == AST_STATE_RINGING) TODO XXX CONSOLE VIDEO IS DISABLED UNTIL IT GETS A MAINTAINER
diff --git a/channels/chan_phone.c b/channels/chan_phone.c
index 6f8f5a4bc24b79f5df31c71dd7401f41ce48f26e..05317479349a374396deab8804edc3235d7f38c0 100644
--- a/channels/chan_phone.c
+++ b/channels/chan_phone.c
@@ -392,7 +392,7 @@ static int phone_setup(struct ast_channel *ast)
 	p = ast_channel_tech_pvt(ast);
 	ioctl(p->fd, PHONE_CPT_STOP);
 	/* Nothing to answering really, just start recording */
-	if (ast->rawreadformat.id == AST_FORMAT_G729A) {
+	if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_G729A) {
 		/* Prefer g729 */
 		ioctl(p->fd, PHONE_REC_STOP);
 		if (p->lastinput.id != AST_FORMAT_G729A) {
@@ -402,7 +402,7 @@ static int phone_setup(struct ast_channel *ast)
 				return -1;
 			}
 		}
-        } else if (ast->rawreadformat.id == AST_FORMAT_G723_1) {
+        } else if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_G723_1) {
 		ioctl(p->fd, PHONE_REC_STOP);
 		if (p->lastinput.id != AST_FORMAT_G723_1) {
 			ast_format_set(&p->lastinput, AST_FORMAT_G723_1, 0);
@@ -411,7 +411,7 @@ static int phone_setup(struct ast_channel *ast)
 				return -1;
 			}
 		}
-	} else if (ast->rawreadformat.id == AST_FORMAT_SLINEAR) {
+	} else if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_SLINEAR) {
 		ioctl(p->fd, PHONE_REC_STOP);
 		if (p->lastinput.id != AST_FORMAT_SLINEAR) {
 			ast_format_set(&p->lastinput, AST_FORMAT_SLINEAR, 0);
@@ -420,7 +420,7 @@ static int phone_setup(struct ast_channel *ast)
 				return -1;
 			}
 		}
-	} else if (ast->rawreadformat.id == AST_FORMAT_ULAW) {
+	} else if (ast_channel_rawreadformat(ast)->id == AST_FORMAT_ULAW) {
 		ioctl(p->fd, PHONE_REC_STOP);
 		if (p->lastinput.id != AST_FORMAT_ULAW) {
 			ast_format_set(&p->lastinput, AST_FORMAT_ULAW, 0);
@@ -431,16 +431,16 @@ static int phone_setup(struct ast_channel *ast)
 		}
 	} else if (p->mode == MODE_FXS) {
 		ioctl(p->fd, PHONE_REC_STOP);
-		if (ast_format_cmp(&p->lastinput, &ast->rawreadformat) == AST_FORMAT_CMP_NOT_EQUAL) {
-			ast_format_copy(&p->lastinput, &ast->rawreadformat);
-			if (ioctl(p->fd, PHONE_REC_CODEC, &ast->rawreadformat)) {
+		if (ast_format_cmp(&p->lastinput, ast_channel_rawreadformat(ast)) == AST_FORMAT_CMP_NOT_EQUAL) {
+			ast_format_copy(&p->lastinput, ast_channel_rawreadformat(ast));
+			if (ioctl(p->fd, PHONE_REC_CODEC, ast_channel_rawreadformat(ast))) {
 				ast_log(LOG_WARNING, "Failed to set codec to %s\n", 
-					ast_getformatname(&ast->rawreadformat));
+					ast_getformatname(ast_channel_rawreadformat(ast)));
 				return -1;
 			}
 		}
 	} else {
-		ast_log(LOG_WARNING, "Can't do format %s\n", ast_getformatname(&ast->rawreadformat));
+		ast_log(LOG_WARNING, "Can't do format %s\n", ast_getformatname(ast_channel_rawreadformat(ast)));
 		return -1;
 	}
 	if (ioctl(p->fd, PHONE_REC_START)) {
@@ -859,16 +859,16 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *cntx,
 		    ioctl(i->fd, PHONE_QUERY_CODEC, &queried_codec) == 0) {
 			if (queried_codec.type == LINEAR16) {
 				ast_format_cap_add(ast_channel_nativeformats(tmp), ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
-				ast_format_copy(&tmp->rawreadformat, &tmpfmt);
-				ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
+				ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
+				ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
 			} else {
 				ast_format_cap_remove(prefcap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
 			}
 		} else {
 			ast_format_cap_copy(ast_channel_nativeformats(tmp), prefcap);
 			ast_best_codec(ast_channel_nativeformats(tmp), &tmpfmt);
-			ast_format_copy(&tmp->rawreadformat, &tmpfmt);
-			ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
+			ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
+			ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
 		}
 		/* no need to call ast_setstate: the channel_alloc already did its job */
 		if (state == AST_STATE_RING)
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 513de4285cde21fae27d059eeb0fc4340e8367a3..cb436529851ffd0919e12ce46fda0088b0b2d2a3 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -6589,8 +6589,8 @@ static int sip_write(struct ast_channel *ast, struct ast_frame *frame)
 			ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s read/write = %s/%s\n",
 				ast_getformatname(&frame->subclass.format),
 				ast_getformatname_multiple(s1, sizeof(s1), ast_channel_nativeformats(ast)),
-				ast_getformatname(&ast->readformat),
-				ast_getformatname(&ast->writeformat));
+				ast_getformatname(ast_channel_readformat(ast)),
+				ast_getformatname(ast_channel_writeformat(ast)));
 			return 0;
 		}
 		if (p) {
@@ -7230,12 +7230,12 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, const char *tit
 	}
 	ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
 
-	ast_format_copy(&tmp->writeformat, &fmt);
-	ast_format_copy(&tmp->rawwriteformat, &fmt);
+	ast_format_copy(ast_channel_writeformat(tmp), &fmt);
+	ast_format_copy(ast_channel_rawwriteformat(tmp), &fmt);
 	ast_rtp_instance_set_write_format(i->rtp, &fmt);
 
-	ast_format_copy(&tmp->readformat, &fmt);
-	ast_format_copy(&tmp->rawreadformat, &fmt);
+	ast_format_copy(ast_channel_readformat(tmp), &fmt);
+	ast_format_copy(ast_channel_rawreadformat(tmp), &fmt);
 	ast_rtp_instance_set_read_format(i->rtp, &fmt);
 
 	ast_channel_tech_pvt_set(tmp, dialog_ref(i, "sip_new: set chan->tech_pvt to i"));
@@ -7579,8 +7579,8 @@ static struct ast_frame *sip_rtp_read(struct ast_channel *ast, struct sip_pvt *p
 			ast_getformatname(&f->subclass.format));
 		ast_format_cap_remove_bytype(ast_channel_nativeformats(p->owner), AST_FORMAT_TYPE_AUDIO);
 		ast_format_cap_add(ast_channel_nativeformats(p->owner), &f->subclass.format);
-		ast_set_read_format(p->owner, &p->owner->readformat);
-		ast_set_write_format(p->owner, &p->owner->writeformat);
+		ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+		ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
 	}
 
 	if (f && p->dsp) {
@@ -9656,8 +9656,8 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action
 		ast_format_cap_joint_append(p->caps, vpeercapability, ast_channel_nativeformats(p->owner));
 		ast_format_cap_joint_append(p->caps, tpeercapability, ast_channel_nativeformats(p->owner));
 
-		ast_set_read_format(p->owner, &p->owner->readformat);
-		ast_set_write_format(p->owner, &p->owner->writeformat);
+		ast_set_read_format(p->owner, ast_channel_readformat(p->owner));
+		ast_set_write_format(p->owner, ast_channel_writeformat(p->owner));
 	}
 
 	if (ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD) && (!ast_sockaddr_isnull(sa) || !ast_sockaddr_isnull(vsa) || !ast_sockaddr_isnull(tsa) || !ast_sockaddr_isnull(isa)) && (!sendonly || sendonly == -1)) {
@@ -22303,8 +22303,8 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
 	}
 
 	/* Make formats okay */
-	transferee->readformat = chan1->readformat;
-	transferee->writeformat = chan1->writeformat;
+	ast_format_copy(ast_channel_readformat(transferee), ast_channel_readformat(chan1));
+	ast_format_copy(ast_channel_writeformat(transferee), ast_channel_writeformat(chan1));
 
 	/* Prepare for taking over the channel */
 	if (ast_channel_masquerade(transferee, chan1)) {
@@ -22327,8 +22327,8 @@ static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct
 	   back the announcement */
 
 	/* Make formats okay */
-	transferer->readformat = chan2->readformat;
-	transferer->writeformat = chan2->writeformat;
+	ast_format_copy(ast_channel_readformat(transferer), ast_channel_readformat(chan2));
+	ast_format_copy(ast_channel_writeformat(transferer), ast_channel_writeformat(chan2));
 	ast_channel_parkinglot_set(transferer, ast_channel_parkinglot(chan2));
 
 	/* Prepare for taking over the channel */
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c
index a63fb6ec64304f50a409856c87d8743d68e1b9f0..6fc1ebc51cbd4142afd4a75e28a0fda0ecf7ee08 100644
--- a/channels/chan_skinny.c
+++ b/channels/chan_skinny.c
@@ -4525,8 +4525,8 @@ static struct ast_frame *skinny_rtp_read(struct skinny_subchannel *sub)
 			if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(ast), &f->subclass.format))) {
 				ast_debug(1, "Oooh, format changed to %s\n", ast_getformatname(&f->subclass.format));
 				ast_format_cap_set(ast_channel_nativeformats(ast), &f->subclass.format);
-				ast_set_read_format(ast, &ast->readformat);
-				ast_set_write_format(ast, &ast->writeformat);
+				ast_set_read_format(ast, ast_channel_readformat(ast));
+				ast_set_write_format(ast, ast_channel_writeformat(ast));
 			}
 		}
 	}
@@ -4560,8 +4560,8 @@ static int skinny_write(struct ast_channel *ast, struct ast_frame *frame)
 			ast_log(LOG_WARNING, "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
 				ast_getformatname(&frame->subclass.format),
 				ast_getformatname_multiple(buf, sizeof(buf), ast_channel_nativeformats(ast)),
-				ast_getformatname(&ast->readformat),
-				ast_getformatname(&ast->writeformat));
+				ast_getformatname(ast_channel_readformat(ast)),
+				ast_getformatname(ast_channel_writeformat(ast)));
 			return -1;
 		}
 	}
@@ -4900,10 +4900,10 @@ static struct ast_channel *skinny_new(struct skinny_line *l, struct skinny_subli
 		if (state == AST_STATE_RING) {
 			ast_channel_rings_set(tmp, 1);
 		}
-		ast_format_copy(&tmp->writeformat, &tmpfmt);
-		ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
-		ast_format_copy(&tmp->readformat, &tmpfmt);
-		ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+		ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
 
 		if (!ast_strlen_zero(l->language))
 			ast_channel_language_set(tmp, l->language);
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index a059d5cb1488835168a2396a76a55f260ebd532a..3a7b37060b0da4fa50649d959539c7dce4de322a 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -2129,19 +2129,19 @@ static void start_rtp(struct unistim_subchannel *sub)
 	sin.sin_port = htons(sub->parent->parent->rtp_port);
 	ast_sockaddr_from_sin(&sin_tmp, &sin);
 	ast_rtp_instance_set_remote_address(sub->rtp, &sin_tmp);
-	if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(sub->owner), &sub->owner->readformat))) {
+	if (!(ast_format_cap_iscompatible(ast_channel_nativeformats(sub->owner), ast_channel_readformat(sub->owner)))) {
 		struct ast_format tmpfmt;
 		char tmp[256];
 		ast_best_codec(ast_channel_nativeformats(sub->owner), &tmpfmt);
 		ast_log(LOG_WARNING,
 				"Our read/writeformat has been changed to something incompatible: %s, using %s best codec from %s\n",
-				ast_getformatname(&sub->owner->readformat),
+				ast_getformatname(ast_channel_readformat(sub->owner)),
 				ast_getformatname(&tmpfmt),
 				ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(sub->owner)));
-		ast_format_copy(&sub->owner->readformat, &tmpfmt);
-		ast_format_copy(&sub->owner->writeformat, &tmpfmt);
+		ast_format_copy(ast_channel_readformat(sub->owner), &tmpfmt);
+		ast_format_copy(ast_channel_writeformat(sub->owner), &tmpfmt);
 	}
-	codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(sub->rtp), 1, &sub->owner->readformat, 0);
+	codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(sub->rtp), 1, ast_channel_readformat(sub->owner), 0);
 	/* Setting up RTP of the phone */
 	if (public_ip.sin_family == 0)  /* NAT IP override ?   */
 		memcpy(&public, &us, sizeof(public));   /* No defined, using IP from recvmsg  */
@@ -2150,12 +2150,12 @@ static void start_rtp(struct unistim_subchannel *sub)
 	if (unistimdebug) {
 		ast_verb(0, "RTP started : Our IP/port is : %s:%hd with codec %s\n",
 			 ast_inet_ntoa(us.sin_addr),
-			 htons(us.sin_port), ast_getformatname(&sub->owner->readformat));
+			 htons(us.sin_port), ast_getformatname(ast_channel_readformat(sub->owner)));
 		ast_verb(0, "Starting phone RTP stack. Our public IP is %s\n",
 					ast_inet_ntoa(public.sin_addr));
 	}
-	if ((sub->owner->readformat.id == AST_FORMAT_ULAW) ||
-		(sub->owner->readformat.id == AST_FORMAT_ALAW)) {
+	if ((ast_channel_readformat(sub->owner)->id == AST_FORMAT_ULAW) ||
+		(ast_channel_readformat(sub->owner)->id == AST_FORMAT_ALAW)) {
 		if (unistimdebug)
 			ast_verb(0, "Sending packet_send_rtp_packet_size for codec %d\n", codec);
 		memcpy(buffsend + SIZE_HEADER, packet_send_rtp_packet_size,
@@ -2250,17 +2250,17 @@ static void start_rtp(struct unistim_subchannel *sub)
 		/* Codec */
 		buffsend[40] = codec;
 		buffsend[41] = codec;
-		if (sub->owner->readformat.id == AST_FORMAT_ULAW)
+		if (ast_channel_readformat(sub->owner)->id == AST_FORMAT_ULAW)
 			buffsend[42] = 1;       /* 1 = 20ms (160 bytes), 2 = 40ms (320 bytes) */
-		else if (sub->owner->readformat.id == AST_FORMAT_ALAW)
+		else if (ast_channel_readformat(sub->owner)->id == AST_FORMAT_ALAW)
 			buffsend[42] = 1;       /* 1 = 20ms (160 bytes), 2 = 40ms (320 bytes) */
-		else if (sub->owner->readformat.id == AST_FORMAT_G723_1)
+		else if (ast_channel_readformat(sub->owner)->id == AST_FORMAT_G723_1)
 			buffsend[42] = 2;       /* 1 = 30ms (24 bytes), 2 = 60 ms (48 bytes) */
-		else if (sub->owner->readformat.id == AST_FORMAT_G729A)
+		else if (ast_channel_readformat(sub->owner)->id == AST_FORMAT_G729A)
 			buffsend[42] = 2;       /* 1 = 10ms (10 bytes), 2 = 20ms (20 bytes) */
 		else
 			ast_log(LOG_WARNING, "Unsupported codec %s!\n",
-					ast_getformatname(&sub->owner->readformat));
+					ast_getformatname(ast_channel_readformat(sub->owner)));
 		/* Source port for transmit RTP and Destination port for receiving RTP */
 		buffsend[45] = (htons(sin.sin_port) & 0xff00) >> 8;
 		buffsend[46] = (htons(sin.sin_port) & 0x00ff);
@@ -4049,8 +4049,8 @@ static struct ast_frame *unistim_rtp_read(const struct ast_channel *ast,
 						ast_getformatname(&f->subclass.format));
 
 				ast_format_cap_set(ast_channel_nativeformats(sub->owner), &f->subclass.format);
-				ast_set_read_format(sub->owner, &sub->owner->readformat);
-				ast_set_write_format(sub->owner, &sub->owner->writeformat);
+				ast_set_read_format(sub->owner, ast_channel_readformat(sub->owner));
+				ast_set_write_format(sub->owner, ast_channel_writeformat(sub->owner));
 			}
 		}
 	}
@@ -4090,8 +4090,8 @@ static int unistim_write(struct ast_channel *ast, struct ast_frame *frame)
 					"Asked to transmit frame type %s, while native formats is %s (read/write = (%s/%s)\n",
 					ast_getformatname(&frame->subclass.format),
 					ast_getformatname_multiple(tmp, sizeof(tmp), ast_channel_nativeformats(ast)),
-					ast_getformatname(&ast->readformat),
-					ast_getformatname(&ast->writeformat));
+					ast_getformatname(ast_channel_readformat(ast)),
+					ast_getformatname(ast_channel_writeformat(ast)));
 			return -1;
 		}
 	}
@@ -4586,10 +4586,10 @@ static struct ast_channel *unistim_new(struct unistim_subchannel *sub, int state
 	if (state == AST_STATE_RING)
 		ast_channel_rings_set(tmp, 1);
 	ast_channel_adsicpe_set(tmp, AST_ADSI_UNAVAILABLE);
-	ast_format_copy(&tmp->writeformat, &tmpfmt);
-	ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
-	ast_format_copy(&tmp->readformat, &tmpfmt);
-	ast_format_copy(&tmp->rawreadformat, &tmpfmt);
+	ast_format_copy(ast_channel_writeformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_readformat(tmp), &tmpfmt);
+	ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
 	ast_channel_tech_pvt_set(tmp, sub);
 	ast_channel_tech_set(tmp, &unistim_tech);
 	if (!ast_strlen_zero(l->language))
diff --git a/channels/chan_usbradio.c b/channels/chan_usbradio.c
index 22dd93bbb856a511b578d4542d9c1031846cfcf4..9560784b812b39085e6141d0f7b5aae327f24efd 100644
--- a/channels/chan_usbradio.c
+++ b/channels/chan_usbradio.c
@@ -2183,8 +2183,8 @@ static struct ast_channel *usbradio_new(struct chan_usbradio_pvt *o, char *ext,
 		setformat(o, O_RDWR);
 	c->fds[0] = o->sounddev;	/* -1 if device closed, override later */
 	ast_format_cap_add(ast_channel_nativeformats(c), &slin);
-	ast_format_set(&c->readformat, AST_FORMAT_SLINEAR, 0);
-	ast_format_set(&c->writeformat, AST_FORMAT_SLINEAR, 0);
+	ast_format_set(ast_channel_readformat(c), AST_FORMAT_SLINEAR, 0);
+	ast_format_set(ast_channel_writeformat(c), AST_FORMAT_SLINEAR, 0);
 	ast_channel_tech_pvt_set(c, o);
 
 	if (!ast_strlen_zero(o->language))
diff --git a/channels/chan_vpb.cc b/channels/chan_vpb.cc
index 551738d37ef5c5331674a9d001a52ae6edab5c8a..4055fc5b52f68dcfb43a6e56d0d2f57d4e35f8bf 100644
--- a/channels/chan_vpb.cc
+++ b/channels/chan_vpb.cc
@@ -2320,7 +2320,7 @@ static void *do_chanreads(void *pvt)
 		ast_mutex_unlock(&p->play_dtmf_lock);
 
 		if (p->owner) {
-			ast_format_copy(&tmpfmt, &p->owner->rawreadformat);
+			ast_format_copy(&tmpfmt, ast_channel_rawreadformat(p->owner));
 		} else {
 			ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0);
 		}
@@ -2458,8 +2458,8 @@ static struct ast_channel *vpb_new(struct vpb_pvt *me, enum ast_channel_state st
 		 * linear since we can then adjust volume in this modules.
 		 */
 		ast_format_cap_add(ast_channel_nativeformats(tmp), ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
-		ast_format_copy(&tmp->rawreadformat, &tmpfmt);
-		ast_format_copy(&tmp->rawwriteformat, &tmpfmt);
+		ast_format_copy(ast_channel_rawreadformat(tmp), &tmpfmt);
+		ast_format_copy(ast_channel_rawwriteformat(tmp), &tmpfmt);
 		if (state == AST_STATE_RING) {
 			ast_channel_rings_set(tmp, 1);
 			cid_name[0] = '\0';
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index ca9741533a428d3cd0593752908ff76541c1ea99..30bf63db91e01aaa9b3e815008197dc62d36c216 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -317,9 +317,9 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
 			tmpcap = ast_format_cap_destroy(tmpcap);
 		}
 	} else if (!strcasecmp(data, "audioreadformat")) {
-		ast_copy_string(buf, ast_getformatname(&chan->readformat), len);
+		ast_copy_string(buf, ast_getformatname(ast_channel_readformat(chan)), len);
 	} else if (!strcasecmp(data, "audiowriteformat")) {
-		ast_copy_string(buf, ast_getformatname(&chan->writeformat), len);
+		ast_copy_string(buf, ast_getformatname(ast_channel_writeformat(chan)), len);
 #ifdef CHANNEL_TRACE
 	} else if (!strcasecmp(data, "trace")) {
 		ast_channel_lock(chan);
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 165e6e5893fcf4ea62c44f550a3bbe7d92c647a1..7b4313b2b9b9dea530dc80c6f1f9c6b81bcdb572 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -869,7 +869,7 @@ struct ast_channel {
 	int __do_not_use_fdno;					/*!< Which fd had an event detected on */
 	int __do_not_use_streamid;					/*!< For streaming playback, the schedule ID */
 	int __do_not_use_vstreamid;					/*!< For streaming video playback, the schedule ID */
-	struct ast_format oldwriteformat;  /*!< Original writer format */
+	struct ast_format __do_not_use_oldwriteformat;  /*!< Original writer format */
 	int __do_not_use_timingfd;					/*!< Timing fd */
 	enum ast_channel_state __do_not_use_state;			/*!< State of line -- Don't write directly, use ast_setstate() */
 	int __do_not_use_rings;					/*!< Number of rings so far */
@@ -885,10 +885,10 @@ struct ast_channel {
 	unsigned int flags;				/*!< channel flags of AST_FLAG_ type */
 	int alertpipe[2];
 	struct ast_format_cap *__do_not_use_nativeformats;         /*!< Kinds of data this channel can natively handle */
-	struct ast_format readformat;            /*!< Requested read format (after translation) */
-	struct ast_format writeformat;           /*!< Requested write format (after translation) */
-	struct ast_format rawreadformat;         /*!< Raw read format (before translation) */
-	struct ast_format rawwriteformat;        /*!< Raw write format (before translation) */
+	struct ast_format __do_not_use_readformat;            /*!< Requested read format (after translation) */
+	struct ast_format __do_not_use_writeformat;           /*!< Requested write format (after translation) */
+	struct ast_format __do_not_use_rawreadformat;         /*!< Raw read format (before translation) */
+	struct ast_format __do_not_use_rawwriteformat;        /*!< Raw write format (before translation) */
 	unsigned int __do_not_use_emulate_dtmf_duration;		/*!< Number of ms left to emulate DTMF for */
 #ifdef HAVE_EPOLL
 	int __do_not_use_epfd;
@@ -3731,4 +3731,12 @@ void ast_channel_adsicpe_set(struct ast_channel *chan, enum ast_channel_adsicpe
 enum ast_channel_state ast_channel_state(const struct ast_channel *chan);
 /* XXX Internal use only, make sure to move later */
 void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state);
+
+/* Format getters */
+struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan);
+struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan);
+struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan);
+struct ast_format *ast_channel_readformat(struct ast_channel *chan);
+struct ast_format *ast_channel_writeformat(struct ast_channel *chan);
+
 #endif /* _ASTERISK_CHANNEL_H */
diff --git a/main/app.c b/main/app.c
index 821c2fbfb2ec4c1e92d36fac1fd6ace89fed53fb..d9f56a4aa3ebfd27b24a2245d898b2f8452a5a3c 100644
--- a/main/app.c
+++ b/main/app.c
@@ -512,7 +512,7 @@ static void *linear_alloc(struct ast_channel *chan, void *params)
 		ast_clear_flag(chan, AST_FLAG_WRITE_INT);
 	}
 
-	ast_format_copy(&ls->origwfmt, &chan->writeformat);
+	ast_format_copy(&ls->origwfmt, ast_channel_writeformat(chan));
 
 	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to linear format (write)\n", ast_channel_name(chan));
@@ -828,7 +828,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
 			return -1;
 		}
 		ast_dsp_set_threshold(sildet, silencethreshold);
-		ast_format_copy(&rfmt, &chan->readformat);
+		ast_format_copy(&rfmt, ast_channel_readformat(chan));
 		res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
 		if (res < 0) {
 			ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
diff --git a/main/bridging.c b/main/bridging.c
index 8fecd53b72369fd9e8abced8306bfa96b8bffced..9a549691f4c25c991d733711a66b7b99edda8ca6 100644
--- a/main/bridging.c
+++ b/main/bridging.c
@@ -553,11 +553,11 @@ int ast_bridge_destroy(struct ast_bridge *bridge)
 static int bridge_make_compatible(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 {
 	struct ast_format formats[2];
-	ast_format_copy(&formats[0], &bridge_channel->chan->readformat);
-	ast_format_copy(&formats[1], &bridge_channel->chan->writeformat);
+	ast_format_copy(&formats[0], ast_channel_readformat(bridge_channel->chan));
+	ast_format_copy(&formats[1], ast_channel_writeformat(bridge_channel->chan));
 
 	/* Are the formats currently in use something ths bridge can handle? */
-	if (!ast_format_cap_iscompatible(bridge->technology->format_capabilities, &bridge_channel->chan->readformat)) {
+	if (!ast_format_cap_iscompatible(bridge->technology->format_capabilities, ast_channel_readformat(bridge_channel->chan))) {
 		struct ast_format best_format;
 		ast_best_codec(bridge->technology->format_capabilities, &best_format);
 
@@ -917,8 +917,8 @@ static enum ast_bridge_channel_state bridge_channel_join(struct ast_bridge_chann
 {
 	struct ast_format formats[2];
 	enum ast_bridge_channel_state state;
-	ast_format_copy(&formats[0], &bridge_channel->chan->readformat);
-	ast_format_copy(&formats[1], &bridge_channel->chan->writeformat);
+	ast_format_copy(&formats[0], ast_channel_readformat(bridge_channel->chan));
+	ast_format_copy(&formats[1], ast_channel_writeformat(bridge_channel->chan));
 
 	/* Record the thread that will be the owner of us */
 	bridge_channel->thread = pthread_self();
@@ -1035,13 +1035,13 @@ static enum ast_bridge_channel_state bridge_channel_join(struct ast_bridge_chann
 	ao2_unlock(bridge_channel->bridge);
 
 	/* Restore original formats of the channel as they came in */
-	if (ast_format_cmp(&bridge_channel->chan->readformat, &formats[0]) == AST_FORMAT_CMP_NOT_EQUAL) {
+	if (ast_format_cmp(ast_channel_readformat(bridge_channel->chan), &formats[0]) == AST_FORMAT_CMP_NOT_EQUAL) {
 		ast_debug(1, "Bridge is returning %p to read format %s(%d)\n", bridge_channel, ast_getformatname(&formats[0]), formats[0].id);
 		if (ast_set_read_format(bridge_channel->chan, &formats[0])) {
 			ast_debug(1, "Bridge failed to return channel %p to read format %s(%d)\n", bridge_channel, ast_getformatname(&formats[0]), formats[0].id);
 		}
 	}
-	if (ast_format_cmp(&bridge_channel->chan->writeformat, &formats[1]) == AST_FORMAT_CMP_NOT_EQUAL) {
+	if (ast_format_cmp(ast_channel_writeformat(bridge_channel->chan), &formats[1]) == AST_FORMAT_CMP_NOT_EQUAL) {
 		ast_debug(1, "Bridge is returning %p to write format %s(%d)\n", bridge_channel, ast_getformatname(&formats[1]), formats[1].id);
 		if (ast_set_write_format(bridge_channel->chan, &formats[1])) {
 			ast_debug(1, "Bridge failed to return channel %p to write format %s(%d)\n", bridge_channel, ast_getformatname(&formats[1]), formats[1].id);
diff --git a/main/channel.c b/main/channel.c
index 35396308bde855f97e0dd93032c263c9b32e8c8f..95fb9259aa6c011d2ab38b1d72f9a3c05079fce4 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -2541,13 +2541,13 @@ static void free_translation(struct ast_channel *clonechan)
 	ast_channel_writetrans_set(clonechan, NULL);
 	ast_channel_readtrans_set(clonechan, NULL);
 	if (ast_format_cap_is_empty(ast_channel_nativeformats(clonechan))) {
-		ast_format_clear(&clonechan->rawwriteformat);
-		ast_format_clear(&clonechan->rawreadformat);
+		ast_format_clear(ast_channel_rawwriteformat(clonechan));
+		ast_format_clear(ast_channel_rawreadformat(clonechan));
 	} else {
 		struct ast_format tmpfmt;
 		ast_best_codec(ast_channel_nativeformats(clonechan), &tmpfmt);
-		ast_format_copy(&clonechan->rawwriteformat, &tmpfmt);
-		ast_format_copy(&clonechan->rawreadformat, &tmpfmt);
+		ast_format_copy(ast_channel_rawwriteformat(clonechan), &tmpfmt);
+		ast_format_copy(ast_channel_rawreadformat(clonechan), &tmpfmt);
 	}
 }
 
@@ -2911,7 +2911,7 @@ static int generator_force(const void *data)
 	if (!tmp || !generate)
 		return 0;
 
-	res = generate(chan, tmp, 0, ast_format_rate(&chan->writeformat) / 50);
+	res = generate(chan, tmp, 0, ast_format_rate(ast_channel_writeformat(chan)) / 50);
 
 	ast_channel_generatordata_set(chan, tmp);
 
@@ -3477,9 +3477,9 @@ static void ast_read_generator_actions(struct ast_channel *chan, struct ast_fram
 
 		ast_channel_generatordata_set(chan, NULL);     /* reset, to let writes go through */
 
-		if (ast_format_cmp(&f->subclass.format, &chan->writeformat) == AST_FORMAT_CMP_NOT_EQUAL) {
+		if (ast_format_cmp(&f->subclass.format, ast_channel_writeformat(chan)) == AST_FORMAT_CMP_NOT_EQUAL) {
 			float factor;
-			factor = ((float) ast_format_rate(&chan->writeformat)) / ((float) ast_format_rate(&f->subclass.format));
+			factor = ((float) ast_format_rate(ast_channel_writeformat(chan))) / ((float) ast_format_rate(&f->subclass.format));
 			samples = (int) ( ((float) f->samples) * factor );
 		} else {
 			samples = f->samples;
@@ -4522,7 +4522,7 @@ int ast_prod(struct ast_channel *chan)
 	/* Send an empty audio frame to get things moving */
 	if (ast_channel_state(chan) != AST_STATE_UP) {
 		ast_debug(1, "Prodding channel '%s'\n", ast_channel_name(chan));
-		ast_format_copy(&a.subclass.format, &chan->rawwriteformat);
+		ast_format_copy(&a.subclass.format, ast_channel_rawwriteformat(chan));
 		a.data.ptr = nothing + AST_FRIENDLY_OFFSET;
 		a.src = "ast_prod"; /* this better match check in ast_write */
 		if (ast_write(chan, &a))
@@ -4778,7 +4778,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
 		}
 
 		/* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */
-		if (ast_format_cmp(&fr->subclass.format, &chan->rawwriteformat) != AST_FORMAT_CMP_NOT_EQUAL) {
+		if (ast_format_cmp(&fr->subclass.format, ast_channel_rawwriteformat(chan)) != AST_FORMAT_CMP_NOT_EQUAL) {
 			f = fr;
 		} else {
 			/* XXX Something is not right we are not compatible with this frame bad things can happen
@@ -4788,10 +4788,10 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
 			 * JIRA issues related to this :-
 			 * ASTERISK-14384, ASTERISK-17502, ASTERISK-17541, ASTERISK-18063, ASTERISK-18325, ASTERISK-18422*/
 			if ((!ast_format_cap_iscompatible(ast_channel_nativeformats(chan), &fr->subclass.format)) &&
-			    (ast_format_cmp(&chan->writeformat, &fr->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
+			    (ast_format_cmp(ast_channel_writeformat(chan), &fr->subclass.format) != AST_FORMAT_CMP_EQUAL)) {
 				char nf[512];
 				ast_log(LOG_WARNING, "Codec mismatch on channel %s setting write format to %s from %s native formats %s\n",
-					ast_channel_name(chan), ast_getformatname(&fr->subclass.format), ast_getformatname(&chan->writeformat),
+					ast_channel_name(chan), ast_getformatname(&fr->subclass.format), ast_getformatname(ast_channel_writeformat(chan)),
 					ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(chan)));
 				ast_set_write_format_by_id(chan, fr->subclass.format.id);
 			}
@@ -5072,8 +5072,8 @@ int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
 
 	res = set_format(chan,
 		cap,
-		&chan->rawreadformat,
-		&chan->readformat,
+		ast_channel_rawreadformat(chan),
+		ast_channel_readformat(chan),
 		&trans,
 		0);
 
@@ -5095,8 +5095,8 @@ int ast_set_read_format_by_id(struct ast_channel *chan, enum ast_format_id id)
 
 	res = set_format(chan,
 		cap,
-		&chan->rawreadformat,
-		&chan->readformat,
+		ast_channel_rawreadformat(chan),
+		ast_channel_readformat(chan),
 		&trans,
 		0);
 
@@ -5111,8 +5111,8 @@ int ast_set_read_format_from_cap(struct ast_channel *chan, struct ast_format_cap
 	int res;
 	res = set_format(chan,
 		cap,
-		&chan->rawreadformat,
-		&chan->readformat,
+		ast_channel_rawreadformat(chan),
+		ast_channel_readformat(chan),
 		&trans,
 		0);
 	ast_channel_readtrans_set(chan, trans);
@@ -5131,8 +5131,8 @@ int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
 
 	res = set_format(chan,
 		cap,
-		&chan->rawwriteformat,
-		&chan->writeformat,
+		ast_channel_rawwriteformat(chan),
+		ast_channel_writeformat(chan),
 		&trans,
 		1);
 
@@ -5154,8 +5154,8 @@ int ast_set_write_format_by_id(struct ast_channel *chan, enum ast_format_id id)
 
 	res = set_format(chan,
 		cap,
-		&chan->rawwriteformat,
-		&chan->writeformat,
+		ast_channel_rawwriteformat(chan),
+		ast_channel_writeformat(chan),
 		&trans,
 		1);
 
@@ -5170,8 +5170,8 @@ int ast_set_write_format_from_cap(struct ast_channel *chan, struct ast_format_ca
 	int res;
 	res = set_format(chan,
 		cap,
-		&chan->rawwriteformat,
-		&chan->writeformat,
+		ast_channel_rawwriteformat(chan),
+		ast_channel_writeformat(chan),
 		&trans,
 		1);
 	ast_channel_writetrans_set(chan, trans);
@@ -5805,8 +5805,8 @@ static int ast_channel_make_compatible_helper(struct ast_channel *from, struct a
 		return 0;
 	}
 
-	if ((ast_format_cmp(&from->readformat, &to->writeformat) != AST_FORMAT_CMP_NOT_EQUAL) &&
-		(ast_format_cmp(&to->readformat, &from->writeformat) != AST_FORMAT_CMP_NOT_EQUAL)) {
+	if ((ast_format_cmp(ast_channel_readformat(from), ast_channel_writeformat(to)) != AST_FORMAT_CMP_NOT_EQUAL) &&
+		(ast_format_cmp(ast_channel_readformat(to), ast_channel_writeformat(from)) != AST_FORMAT_CMP_NOT_EQUAL)) {
 		/* Already compatible!  Moving on ... */
 		return 0;
 	}
@@ -6449,8 +6449,8 @@ int ast_do_masquerade(struct ast_channel *original)
 	char masqn[AST_CHANNEL_NAME];
 	char zombn[AST_CHANNEL_NAME];
 
-	ast_format_copy(&rformat, &original->readformat);
-	ast_format_copy(&wformat, &original->writeformat);
+	ast_format_copy(&rformat, ast_channel_readformat(original));
+	ast_format_copy(&wformat, ast_channel_writeformat(original));
 
 	/* XXX This operation is a bit odd.  We're essentially putting the guts of
 	 * the clone channel into the original channel.  Start by killing off the
@@ -6621,13 +6621,13 @@ int ast_do_masquerade(struct ast_channel *original)
 	}
 
 	/* Swap the raw formats */
-	ast_format_copy(&tmp_format, &original->rawreadformat);
-	ast_format_copy(&original->rawreadformat, &clonechan->rawreadformat);
-	ast_format_copy(&clonechan->rawreadformat, &tmp_format);
+	ast_format_copy(&tmp_format, ast_channel_rawreadformat(original));
+	ast_format_copy(ast_channel_rawreadformat(original), ast_channel_rawreadformat(clonechan));
+	ast_format_copy(ast_channel_rawreadformat(clonechan), &tmp_format);
 
-	ast_format_copy(&tmp_format, &original->rawwriteformat);
-	ast_format_copy(&original->rawwriteformat, &clonechan->rawwriteformat);
-	ast_format_copy(&clonechan->rawwriteformat, &tmp_format);
+	ast_format_copy(&tmp_format, ast_channel_rawwriteformat(original));
+	ast_format_copy(ast_channel_rawwriteformat(original), ast_channel_rawwriteformat(clonechan));
+	ast_format_copy(ast_channel_rawwriteformat(clonechan), &tmp_format);
 
 	clonechan->_softhangup = AST_SOFTHANGUP_DEV;
 
@@ -7525,8 +7525,8 @@ enum ast_bridge_result ast_channel_bridge(struct ast_channel *c0, struct ast_cha
 			}
 		}
 
-		if (((ast_format_cmp(&c1->readformat, &c0->writeformat) == AST_FORMAT_CMP_NOT_EQUAL) ||
-			(ast_format_cmp(&c0->readformat, &c1->writeformat) == AST_FORMAT_CMP_NOT_EQUAL) ||
+		if (((ast_format_cmp(ast_channel_readformat(c1), ast_channel_writeformat(c0)) == AST_FORMAT_CMP_NOT_EQUAL) ||
+			(ast_format_cmp(ast_channel_readformat(c0), ast_channel_writeformat(c1)) == AST_FORMAT_CMP_NOT_EQUAL) ||
 		    !ast_format_cap_identical(ast_channel_nativeformats(c0), o0nativeformats) ||
 			!ast_format_cap_identical(ast_channel_nativeformats(c1), o1nativeformats)) &&
 		    !(ast_channel_generator(c0) || ast_channel_generator(c1))) {
@@ -7653,7 +7653,7 @@ static void *tonepair_alloc(struct ast_channel *chan, void *params)
 
 	if (!(ts = ast_calloc(1, sizeof(*ts))))
 		return NULL;
-	ast_format_copy(&ts->origwfmt, &chan->writeformat);
+	ast_format_copy(&ts->origwfmt, ast_channel_writeformat(chan));
 	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", ast_channel_name(chan));
 		tonepair_release(NULL, ts);
@@ -8082,7 +8082,7 @@ struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_cha
 		return NULL;
 	}
 
-	ast_format_copy(&state->old_write_format, &chan->writeformat);
+	ast_format_copy(&state->old_write_format, ast_channel_writeformat(chan));
 
 	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
 		ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n");
diff --git a/main/channel_internal_api.c b/main/channel_internal_api.c
index 0b2d7c9b89d37d30ea16fc91fd33487d05944910..df6345b332c333a606d293b4d4e1d1d7879fc3ae 100644
--- a/main/channel_internal_api.c
+++ b/main/channel_internal_api.c
@@ -137,11 +137,11 @@ int ast_channel_data_add_structure(struct ast_data *tree,
 		}
 	}
 
-	ast_data_add_codec(tree, "oldwriteformat", &chan->oldwriteformat);
-	ast_data_add_codec(tree, "readformat", &chan->readformat);
-	ast_data_add_codec(tree, "writeformat", &chan->writeformat);
-	ast_data_add_codec(tree, "rawreadformat", &chan->rawreadformat);
-	ast_data_add_codec(tree, "rawwriteformat", &chan->rawwriteformat);
+	ast_data_add_codec(tree, "oldwriteformat", ast_channel_oldwriteformat(chan));
+	ast_data_add_codec(tree, "readformat", ast_channel_readformat(chan));
+	ast_data_add_codec(tree, "writeformat", ast_channel_writeformat(chan));
+	ast_data_add_codec(tree, "rawreadformat", ast_channel_rawreadformat(chan));
+	ast_data_add_codec(tree, "rawwriteformat", ast_channel_rawwriteformat(chan));
 	ast_data_add_codecs(tree, "nativeformats", ast_channel_nativeformats(chan));
 
 	/* state */
@@ -684,3 +684,23 @@ void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state valu
 {
 	chan->__do_not_use_state = value;
 }
+struct ast_format *ast_channel_oldwriteformat(struct ast_channel *chan)
+{
+	return &chan->__do_not_use_oldwriteformat;
+}
+struct ast_format *ast_channel_rawreadformat(struct ast_channel *chan)
+{
+	return &chan->__do_not_use_rawreadformat;
+}
+struct ast_format *ast_channel_rawwriteformat(struct ast_channel *chan)
+{
+	return &chan->__do_not_use_rawwriteformat;
+}
+struct ast_format *ast_channel_readformat(struct ast_channel *chan)
+{
+	return &chan->__do_not_use_readformat;
+}
+struct ast_format *ast_channel_writeformat(struct ast_channel *chan)
+{
+	return &chan->__do_not_use_writeformat;
+}
diff --git a/main/cli.c b/main/cli.c
index c6355835be53eab85351fc97c8f15b070d10bdc1..ae9e9d38338a4565ac200b04a9ba6d0a0d3c1500 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -1484,8 +1484,8 @@ static char *handle_showchan(struct ast_cli_entry *e, int cmd, struct ast_cli_ar
 		ast_channel_language(c),	
 		ast_state2str(ast_channel_state(c)), ast_channel_state(c), ast_channel_rings(c), 
 		ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(c)),
-		ast_getformatname(&c->writeformat),
-		ast_getformatname(&c->readformat),
+		ast_getformatname(ast_channel_writeformat(c)),
+		ast_getformatname(ast_channel_readformat(c)),
 		ast_channel_writetrans(c) ? "Yes" : "No",
 		ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
 		ast_channel_readtrans(c) ? "Yes" : "No",
diff --git a/main/features.c b/main/features.c
index 96f76d9cbafb99742711ee404c60d4fcc7dacfe5..b329c6acc6779c16a24c0ec82f0e444226cae7ad 100644
--- a/main/features.c
+++ b/main/features.c
@@ -876,8 +876,8 @@ static void check_goto_on_transfer(struct ast_channel *chan)
 	}
 
 	/* Make formats okay */
-	xferchan->readformat = chan->readformat;
-	xferchan->writeformat = chan->writeformat;
+	ast_format_copy(ast_channel_readformat(xferchan), ast_channel_readformat(chan));
+	ast_format_copy(ast_channel_writeformat(xferchan), ast_channel_writeformat(chan));
 
 	if (ast_channel_masquerade(xferchan, chan)) {
 		/* Failed to setup masquerade. */
@@ -1672,8 +1672,8 @@ static int masq_park_call(struct ast_channel *rchan, struct ast_channel *peer, s
 	}
 
 	/* Make formats okay */
-	chan->readformat = rchan->readformat;
-	chan->writeformat = rchan->writeformat;
+	ast_format_copy(ast_channel_readformat(chan), ast_channel_readformat(rchan));
+	ast_format_copy(ast_channel_writeformat(chan), ast_channel_writeformat(rchan));
 
 	if (ast_channel_masquerade(chan, rchan)) {
 		park_space_abort(args->pu);
@@ -2726,8 +2726,8 @@ static int builtin_atxfer(struct ast_channel *chan, struct ast_channel *peer, st
 	ast_channel_visible_indication_set(xferchan, AST_CONTROL_RINGING);
 
 	/* Make formats okay */
-	xferchan->readformat = transferee->readformat;
-	xferchan->writeformat = transferee->writeformat;
+	ast_format_copy(ast_channel_readformat(xferchan), ast_channel_readformat(transferee));
+	ast_format_copy(ast_channel_writeformat(xferchan), ast_channel_writeformat(transferee));
 
 	ast_channel_masquerade(xferchan, transferee);
 	ast_explicit_goto(xferchan, ast_channel_context(transferee), ast_channel_exten(transferee), ast_channel_priority(transferee));
@@ -6828,8 +6828,8 @@ static void do_bridge_masquerade(struct ast_channel *chan, struct ast_channel *t
 	ast_moh_stop(chan);
 	ast_channel_lock_both(chan, tmpchan);
 	ast_setstate(tmpchan, ast_channel_state(chan));
-	tmpchan->readformat = chan->readformat;
-	tmpchan->writeformat = chan->writeformat;
+	ast_format_copy(ast_channel_readformat(tmpchan), ast_channel_readformat(chan));
+	ast_format_copy(ast_channel_writeformat(tmpchan), ast_channel_writeformat(chan));
 	ast_channel_unlock(chan);
 	ast_channel_unlock(tmpchan);
 
@@ -7937,10 +7937,10 @@ static struct ast_channel *create_test_channel(const struct ast_channel_tech *fa
 	/* normally this is done in the channel driver */
 	ast_format_cap_add(ast_channel_nativeformats(test_channel1), ast_format_set(&tmp_fmt, AST_FORMAT_GSM, 0));
 
-	ast_format_set(&test_channel1->writeformat, AST_FORMAT_GSM, 0);
-	ast_format_set(&test_channel1->rawwriteformat, AST_FORMAT_GSM, 0);
-	ast_format_set(&test_channel1->readformat, AST_FORMAT_GSM, 0);
-	ast_format_set(&test_channel1->rawreadformat, AST_FORMAT_GSM, 0);
+	ast_format_set(ast_channel_writeformat(test_channel1), AST_FORMAT_GSM, 0);
+	ast_format_set(ast_channel_rawwriteformat(test_channel1), AST_FORMAT_GSM, 0);
+	ast_format_set(ast_channel_readformat(test_channel1), AST_FORMAT_GSM, 0);
+	ast_format_set(ast_channel_rawreadformat(test_channel1), AST_FORMAT_GSM, 0);
 
 	ast_channel_tech_set(test_channel1, fake_tech);
 
diff --git a/main/file.c b/main/file.c
index 5341e8f18c3f5d14cc9e78404f769b2d3761ff29..bf9f6831aec0f3f4574284f8c6cb0c181113fce4 100644
--- a/main/file.c
+++ b/main/file.c
@@ -131,8 +131,8 @@ int ast_stopstream(struct ast_channel *tmp)
 	if (ast_channel_stream(tmp)) {
 		ast_closestream(ast_channel_stream(tmp));
 		ast_channel_stream_set(tmp, NULL);
-		if (tmp->oldwriteformat.id && ast_set_write_format(tmp, &tmp->oldwriteformat))
-			ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_getformatname(&tmp->oldwriteformat));
+		if (ast_channel_oldwriteformat(tmp)->id && ast_set_write_format(tmp, ast_channel_oldwriteformat(tmp)))
+			ast_log(LOG_WARNING, "Unable to restore format back to %s\n", ast_getformatname(ast_channel_oldwriteformat(tmp)));
 	}
 	/* Stop the video stream too */
 	if (ast_channel_vstream(tmp) != NULL) {
@@ -467,7 +467,7 @@ static int filehelper(const char *filename, const void *arg2, const char *fmt, c
 				FILE *bfile;
 				struct ast_filestream *s;
 
-				if ((ast_format_cmp(&chan->writeformat, &f->format) == AST_FORMAT_CMP_NOT_EQUAL) &&
+				if ((ast_format_cmp(ast_channel_writeformat(chan), &f->format) == AST_FORMAT_CMP_NOT_EQUAL) &&
 				     !(((AST_FORMAT_GET_TYPE(f->format.id) == AST_FORMAT_TYPE_AUDIO) && fmt) ||
 					  ((AST_FORMAT_GET_TYPE(f->format.id) == AST_FORMAT_TYPE_VIDEO) && fmt))) {
 					ast_free(fn);
@@ -701,7 +701,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
 	}
 
 	/* Set the channel to a format we can work with and save off the previous format. */
-	ast_format_copy(&chan->oldwriteformat, &chan->writeformat);
+	ast_format_copy(ast_channel_oldwriteformat(chan), ast_channel_writeformat(chan));
 	/* Set the channel to the best format that exists for the file. */
 	res = ast_set_write_format_from_cap(chan, file_fmt_cap);
 	/* don't need this anymore now that the channel's write format is set. */
@@ -1049,7 +1049,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
 	res = ast_playstream(fs);
 	if (!res && vfs)
 		res = ast_playstream(vfs);
-	ast_verb(3, "<%s> Playing '%s.%s' (language '%s')\n", ast_channel_name(chan), filename, ast_getformatname(&chan->writeformat), preflang ? preflang : "default");
+	ast_verb(3, "<%s> Playing '%s.%s' (language '%s')\n", ast_channel_name(chan), filename, ast_getformatname(ast_channel_writeformat(chan)), preflang ? preflang : "default");
 
 	return res;
 }
diff --git a/main/indications.c b/main/indications.c
index b07de4bc4a629fda90ca411870248f6912d43fbb..20ce4b894b41e74830db227e1f46112627e11596 100644
--- a/main/indications.c
+++ b/main/indications.c
@@ -147,7 +147,7 @@ static void *playtones_alloc(struct ast_channel *chan, void *params)
 		return NULL;
 	}
 
-	ast_format_copy(&ps->origwfmt, &chan->writeformat);
+	ast_format_copy(&ps->origwfmt, ast_channel_writeformat(chan));
 
 	if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", ast_channel_name(chan));
diff --git a/main/pbx.c b/main/pbx.c
index 626d6e8aac093bc3b18ce1377f3c380f8f44e62a..bbf5ad74b3057fa0a75a0f668cc83286de0ca4d1 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -8347,8 +8347,8 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
 	tmpvars.name = ast_strdupa(ast_channel_name(chan));
 	tmpvars.amaflags = ast_channel_amaflags(chan);
 	tmpvars.state = ast_channel_state(chan);
-	ast_format_copy(&tmpvars.writeformat, &chan->writeformat);
-	ast_format_copy(&tmpvars.readformat, &chan->readformat);
+	ast_format_copy(&tmpvars.writeformat, ast_channel_writeformat(chan));
+	ast_format_copy(&tmpvars.readformat, ast_channel_readformat(chan));
 	tmpvars.cdr = ast_channel_cdr(chan) ? ast_cdr_dup(ast_channel_cdr(chan)) : NULL;
 
 	ast_channel_unlock(chan);
@@ -8368,8 +8368,8 @@ int ast_async_goto(struct ast_channel *chan, const char *context, const char *ex
 	}
 
 	/* Make formats okay */
-	ast_format_copy(&tmpchan->readformat, &tmpvars.readformat);
-	ast_format_copy(&tmpchan->writeformat, &tmpvars.writeformat);
+	ast_format_copy(ast_channel_readformat(tmpchan), &tmpvars.readformat);
+	ast_format_copy(ast_channel_writeformat(tmpchan), &tmpvars.writeformat);
 
 	/* Setup proper location. Never hold another channel lock while calling this function. */
 	ast_explicit_goto(tmpchan, S_OR(context, tmpvars.context), S_OR(exten, tmpvars.exten), priority);
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index 518ac140c6bc44c63918d4ff15c9deb45c758674..80f154f369bfe2b5c760d81e344517ecf66f1ed8 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -836,8 +836,8 @@ static enum ast_bridge_result local_bridge_loop(struct ast_channel *c0, struct a
 	cs[2] = NULL;
 	for (;;) {
 		/* If the underlying formats have changed force this bridge to break */
-		if ((ast_format_cmp(&c0->rawreadformat, &c1->rawwriteformat) == AST_FORMAT_CMP_NOT_EQUAL) ||
-			(ast_format_cmp(&c1->rawreadformat, &c0->rawwriteformat) == AST_FORMAT_CMP_NOT_EQUAL)) {
+		if ((ast_format_cmp(ast_channel_rawreadformat(c0), ast_channel_rawwriteformat(c1)) == AST_FORMAT_CMP_NOT_EQUAL) ||
+			(ast_format_cmp(ast_channel_rawreadformat(c1), ast_channel_rawwriteformat(c0)) == AST_FORMAT_CMP_NOT_EQUAL)) {
 			ast_debug(1, "rtp-engine-local-bridge: Oooh, formats changed, backing out\n");
 			res = AST_BRIDGE_FAILED_NOWARN;
 			break;
diff --git a/res/res_adsi.c b/res/res_adsi.c
index 0987b494a2f00e8158f547365ad6797fa2c1343c..30d8cfc851387e1f6d4a2fd8aa6264cab0b8beab 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -371,8 +371,8 @@ int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message_full)(struct ast_channel *ch
 	struct ast_format writeformat;
 	struct ast_format readformat;
 
-	ast_format_copy(&writeformat, &chan->writeformat);
-	ast_format_copy(&readformat, &chan->readformat);
+	ast_format_copy(&writeformat, ast_channel_writeformat(chan));
+	ast_format_copy(&readformat, ast_channel_readformat(chan));
 
 	for (x = 0; x < msglen; x += (msg[x+1]+2)) {
 		if (msg[x] == ADSI_SWITCH_TO_DATA) {
diff --git a/res/res_agi.c b/res/res_agi.c
index b8c39f929ad040e49fd4b478eda5528b71120483..4ea10bf30619938a9b95cbb39b8cbd479286b7dd 100644
--- a/res/res_agi.c
+++ b/res/res_agi.c
@@ -2289,7 +2289,7 @@ static int handle_recordfile(struct ast_channel *chan, AGI *agi, int argc, const
 	}
 
 	if (silence > 0) {
-		ast_format_copy(&rfmt, &chan->readformat);
+		ast_format_copy(&rfmt, ast_channel_readformat(chan));
 		res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
 		if (res < 0) {
 			ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
@@ -2937,7 +2937,7 @@ static int handle_speechrecognize(struct ast_channel *chan, AGI *agi, int argc,
 		offset = atoi(argv[4]);
 
 	/* We want frames coming in signed linear */
-	ast_format_copy(&old_read_format, &chan->readformat);
+	ast_format_copy(&old_read_format, ast_channel_readformat(chan));
 	if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
 		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
@@ -3934,7 +3934,7 @@ static int eagi_exec(struct ast_channel *chan, const char *data)
 		ast_log(LOG_ERROR, "EAGI cannot be run on a dead/hungup channel, please use AGI.\n");
 		return 0;
 	}
-	ast_format_copy(&readformat, &chan->readformat);
+	ast_format_copy(&readformat, ast_channel_readformat(chan));
 	if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", ast_channel_name(chan));
 		return -1;
diff --git a/res/res_calendar.c b/res/res_calendar.c
index 4bcb2639b024b1e076a09d68d992b11e95afa057..5ddcaae07c7d5c533882f1f0a6b04134d669576d 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -746,12 +746,12 @@ static void *do_notify(void *data)
 	}
 
 	ast_channel_tech_set(chan, &null_tech);
-	ast_format_set(&chan->writeformat, AST_FORMAT_SLINEAR, 0);
-	ast_format_set(&chan->readformat, AST_FORMAT_SLINEAR, 0);
-	ast_format_set(&chan->rawwriteformat, AST_FORMAT_SLINEAR, 0);
-	ast_format_set(&chan->rawreadformat, AST_FORMAT_SLINEAR, 0);
+	ast_format_set(ast_channel_writeformat(chan), AST_FORMAT_SLINEAR, 0);
+	ast_format_set(ast_channel_readformat(chan), AST_FORMAT_SLINEAR, 0);
+	ast_format_set(ast_channel_rawwriteformat(chan), AST_FORMAT_SLINEAR, 0);
+	ast_format_set(ast_channel_rawreadformat(chan), AST_FORMAT_SLINEAR, 0);
 	/* clear native formats and set to slinear. write format is signlear so just use that to set it */
-	ast_format_cap_set(ast_channel_nativeformats(chan), &chan->writeformat);
+	ast_format_cap_set(ast_channel_nativeformats(chan), ast_channel_writeformat(chan));
 
 	if (!(datastore = ast_datastore_alloc(&event_notification_datastore, NULL))) {
 		ast_log(LOG_ERROR, "Could not allocate datastore, notification not being sent!\n");
diff --git a/res/res_fax.c b/res/res_fax.c
index cea74b726d55744d4d5269ca318e5f0397b8c025..5b9df525288fc70582423076572d131bf2827cd2 100644
--- a/res/res_fax.c
+++ b/res/res_fax.c
@@ -1355,7 +1355,7 @@ static int generic_fax_exec(struct ast_channel *chan, struct ast_fax_session_det
 	if (details->caps & AST_FAX_TECH_AUDIO) {
 		expected_frametype = AST_FRAME_VOICE;;
 		ast_format_set(&expected_framesubclass.format, AST_FORMAT_SLINEAR, 0);
-		ast_format_copy(&orig_write_format, &chan->writeformat);
+		ast_format_copy(&orig_write_format, ast_channel_writeformat(chan));
 		if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
 			ast_log(LOG_ERROR, "channel '%s' failed to set write format to signed linear'.\n", ast_channel_name(chan));
  			ao2_lock(faxregistry.container);
@@ -1365,7 +1365,7 @@ static int generic_fax_exec(struct ast_channel *chan, struct ast_fax_session_det
 			ast_channel_unlock(chan);
 			return -1;
 		}
-		ast_format_copy(&orig_read_format, &chan->readformat);
+		ast_format_copy(&orig_read_format, ast_channel_readformat(chan));
 		if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
 			ast_log(LOG_ERROR, "channel '%s' failed to set read format to signed linear.\n", ast_channel_name(chan));
  			ao2_lock(faxregistry.container);
@@ -3004,11 +3004,11 @@ static struct ast_frame *fax_gateway_framehook(struct ast_channel *chan, struct
 
 		/* we are bridged, change r/w formats to SLIN for v21 preamble
 		 * detection and T.30 */
-		ast_format_copy(&gateway->chan_read_format, &chan->readformat);
-		ast_format_copy(&gateway->chan_write_format, &chan->readformat);
+		ast_format_copy(&gateway->chan_read_format, ast_channel_readformat(chan));
+		ast_format_copy(&gateway->chan_write_format, ast_channel_readformat(chan));
 
-		ast_format_copy(&gateway->peer_read_format, &peer->readformat);
-		ast_format_copy(&gateway->peer_write_format, &peer->readformat);
+		ast_format_copy(&gateway->peer_read_format, ast_channel_readformat(peer));
+		ast_format_copy(&gateway->peer_write_format, ast_channel_readformat(peer));
 
 		ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
 		ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
@@ -3272,8 +3272,8 @@ static struct ast_frame *fax_detect_framehook(struct ast_channel *chan, struct a
 	switch (event) {
 	case AST_FRAMEHOOK_EVENT_ATTACHED:
 		/* Setup format for DSP on ATTACH*/
-		ast_format_copy(&faxdetect->orig_format, &chan->readformat);
-		switch (chan->readformat.id) {
+		ast_format_copy(&faxdetect->orig_format, ast_channel_readformat(chan));
+		switch (ast_channel_readformat(chan)->id) {
 			case AST_FORMAT_SLINEAR:
 			case AST_FORMAT_ALAW:
 			case AST_FORMAT_ULAW:
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index eb4330e21792e7ce33e5a976d7d656c48e662408..6411af2426e2acb0dc4bf2d5a1068e9f4d4f5fe9 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -392,7 +392,7 @@ static void moh_files_write_format_change(struct ast_channel *chan, void *data)
 	if (&state->origwfmt.id) {
 		struct ast_format tmp;
 
-		ast_format_copy(&tmp, &chan->writeformat);
+		ast_format_copy(&tmp, ast_channel_writeformat(chan));
 		if (state->mohwfmt.id) {
 			ast_format_clear(&state->origwfmt);
 			ast_set_write_format(chan, &state->mohwfmt);
@@ -470,8 +470,8 @@ static void *moh_files_alloc(struct ast_channel *chan, void *params)
 	}
 
 	state->class = mohclass_ref(class, "Reffing music class for channel");
-	ast_format_copy(&state->origwfmt, &chan->writeformat);
-	ast_format_copy(&state->mohwfmt, &chan->writeformat);
+	ast_format_copy(&state->origwfmt, ast_channel_writeformat(chan));
+	ast_format_copy(&state->mohwfmt, ast_channel_writeformat(chan));
 
 	/* For comparison on restart of MOH (see above) */
 	ast_copy_string(state->name, class->name, sizeof(state->name));
@@ -992,7 +992,7 @@ static void *moh_alloc(struct ast_channel *chan, void *params)
 	}
 
 	if ((res = mohalloc(class))) {
-		ast_format_copy(&res->origwfmt, &chan->writeformat);
+		ast_format_copy(&res->origwfmt, ast_channel_writeformat(chan));
 		if (ast_set_write_format(chan, &class->format)) {
 			ast_log(LOG_WARNING, "Unable to set channel '%s' to format '%s'\n", ast_channel_name(chan), ast_codec2str(&class->format));
 			moh_release(NULL, res);